From 287c1c4ffa0c0df25395d7d15695da8a69c76670 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 28 Jan 2016 16:03:49 +0100 Subject: [PATCH] Some code cleanup. --- app/Http/Controllers/RuleController.php | 64 ++++++++++++------------- app/Models/Account.php | 2 + app/Models/Category.php | 1 + app/Models/PiggyBank.php | 1 + app/Models/Transaction.php | 2 + app/Models/TransactionJournal.php | 1 + 6 files changed, 39 insertions(+), 32 deletions(-) diff --git a/app/Http/Controllers/RuleController.php b/app/Http/Controllers/RuleController.php index 53091dc45d..efb3f4e474 100644 --- a/app/Http/Controllers/RuleController.php +++ b/app/Http/Controllers/RuleController.php @@ -214,7 +214,7 @@ class RuleController extends Controller $repository->reorderRuleActions($rule, $ids); } - return Response::json(true); + return Response::json('true'); } @@ -231,7 +231,7 @@ class RuleController extends Controller $repository->reorderRuleTriggers($rule, $ids); } - return Response::json(true); + return Response::json('true'); } @@ -446,21 +446,21 @@ class RuleController extends Controller { $newIndex = 0; $actions = []; - if (is_array(Input::old('rule-action'))) { - foreach (Input::old('rule-action') as $index => $entry) { - $count = ($newIndex + 1); - $checked = isset(Input::old('rule-action-stop')[$index]) ? true : false; - $actions[] = view( - 'rules.partials.action', - [ - 'oldTrigger' => $entry, - 'oldValue' => Input::old('rule-action-value')[$index], - 'oldChecked' => $checked, - 'count' => $count, - ] - )->render(); - $newIndex++; - } + /** @var array $oldActions */ + $oldActions = is_array(Input::old('rule-action')) ? Input::old('rule-action') : []; + foreach ($oldActions as $index => $entry) { + $count = ($newIndex + 1); + $checked = isset(Input::old('rule-action-stop')[$index]) ? true : false; + $actions[] = view( + 'rules.partials.action', + [ + 'oldTrigger' => $entry, + 'oldValue' => Input::old('rule-action-value')[$index], + 'oldChecked' => $checked, + 'count' => $count, + ] + )->render(); + $newIndex++; } return $actions; @@ -473,21 +473,21 @@ class RuleController extends Controller { $newIndex = 0; $triggers = []; - if (is_array(Input::old('rule-trigger'))) { - foreach (Input::old('rule-trigger') as $index => $entry) { - $count = ($newIndex + 1); - $oldChecked = isset(Input::old('rule-trigger-stop')[$index]) ? true : false; - $triggers[] = view( - 'rules.partials.trigger', - [ - 'oldTrigger' => $entry, - 'oldValue' => Input::old('rule-trigger-value')[$index], - 'oldChecked' => $oldChecked, - 'count' => $count, - ] - )->render(); - $newIndex++; - } + /** @var array $oldTriggers */ + $oldTriggers = is_array(Input::old('rule-trigger')) ? Input::old('rule-trigger') : []; + foreach ($oldTriggers as $index => $entry) { + $count = ($newIndex + 1); + $oldChecked = isset(Input::old('rule-trigger-stop')[$index]) ? true : false; + $triggers[] = view( + 'rules.partials.trigger', + [ + 'oldTrigger' => $entry, + 'oldValue' => Input::old('rule-trigger-value')[$index], + 'oldChecked' => $oldChecked, + 'count' => $count, + ] + )->render(); + $newIndex++; } return $triggers; diff --git a/app/Models/Account.php b/app/Models/Account.php index 6bb5b82eda..eb76d2ae4b 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -37,6 +37,8 @@ use Watson\Validating\ValidatingTrait; * @property string $endBalance * @property float $difference * @property Carbon $lastActivityDate + * @property float $piggyBalance + * @property float $percentage */ class Account extends Model { diff --git a/app/Models/Category.php b/app/Models/Category.php index 7fc528ca5b..b601995bb0 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -24,6 +24,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @property string $dateFormatted * @property float $spent * @property Carbon $lastActivity + * @property string $type */ class Category extends Model { diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php index 73c1ab74db..fd8de16152 100644 --- a/app/Models/PiggyBank.php +++ b/app/Models/PiggyBank.php @@ -28,6 +28,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @property-read Collection|PiggyBankRepetition[] $piggyBankRepetitions * @property-read Collection|PiggyBankEvent[] $piggyBankEvents * @property string $reminder + * @property PiggyBankRepetition $currentRep */ class PiggyBank extends Model { diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index 2357277d52..cc0561e241 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -22,6 +22,8 @@ use Watson\Validating\ValidatingTrait; * @property-read TransactionJournal $transactionJournal * @method static Builder|Transaction after($date) * @method static Builder|Transaction before($date) + * @property float $before + * @property float $after */ class Transaction extends Model { diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php index d24cadb163..573ecb63b4 100644 --- a/app/Models/TransactionJournal.php +++ b/app/Models/TransactionJournal.php @@ -56,6 +56,7 @@ use Watson\Validating\ValidatingTrait; * @method static Builder|TransactionJournal onDate($date) * @method static Builder|TransactionJournal transactionTypes($types) * @method static Builder|TransactionJournal withRelevantData() + * @property string $type */ class TransactionJournal extends Model {