diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index afacfa1b23..a0be3ef501 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -1,6 +1,5 @@ setPath('accounts/show/' . $account->id); - return view('accounts.show', compact('account', 'what', 'subTitleIcon', 'journals', 'subTitle')); } @@ -192,7 +190,7 @@ class AccountController extends Controller ]; $account = $repository->store($accountData); - Session::flash('success', 'New account "' . $account->name . '" stored!'); + Session::flash('success', 'New account "' . $account->name . '" stored!'); if (intval(Input::get('create_another')) === 1) { return Redirect::route('accounts.create', $request->input('what'))->withInput(); diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php index 6a78a4718f..f269af2954 100644 --- a/app/Http/Controllers/BillController.php +++ b/app/Http/Controllers/BillController.php @@ -173,7 +173,7 @@ class BillController extends Controller */ public function show(Bill $bill, BillRepositoryInterface $repository) { - $journals = $repository->getJournals($bill); + $journals = $repository->getJournals($bill); $bill->nextExpectedMatch = $repository->nextExpectedMatch($bill); $hideBill = true; diff --git a/app/Http/Controllers/HelpController.php b/app/Http/Controllers/HelpController.php index f8041286f7..09e99e2b4b 100644 --- a/app/Http/Controllers/HelpController.php +++ b/app/Http/Controllers/HelpController.php @@ -3,9 +3,10 @@ use Cache; use ErrorException; use League\CommonMark\CommonMarkConverter; +use Log; use Response; use Route; -use Log; + /** * Class HelpController * diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 2f029fde65..202cb7ea18 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -2,12 +2,13 @@ use Auth; use Carbon\Carbon; +use Config; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use Input; use Preferences; -use Session; use Redirect; -use Config; +use Session; + /** * Class HomeController * @@ -31,8 +32,10 @@ class HomeController extends Controller Session::put('end', $end); } - public function flush() { + public function flush() + { Session::clear(); + return Redirect::route('index'); } @@ -42,7 +45,7 @@ class HomeController extends Controller public function index(AccountRepositoryInterface $repository) { - $types = Config::get('firefly.accountTypesByIdentifier.asset'); + $types = Config::get('firefly.accountTypesByIdentifier.asset'); $count = $repository->countAccounts($types); $title = 'Firefly'; $subTitle = 'What\'s playing?'; diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php index fb69b046d9..f620da02fd 100644 --- a/app/Http/Controllers/JsonController.php +++ b/app/Http/Controllers/JsonController.php @@ -2,7 +2,6 @@ use Amount; use Auth; -use Carbon\Carbon; use DB; use FireflyIII\Models\Account; use FireflyIII\Models\Bill; diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php index 51349c6371..d219359656 100644 --- a/app/Http/Controllers/PiggyBankController.php +++ b/app/Http/Controllers/PiggyBankController.php @@ -16,8 +16,8 @@ use Input; use Redirect; use Session; use Steam; -use View; use URL; +use View; /** * Class PiggyBankController @@ -170,7 +170,7 @@ class PiggyBankController extends Controller if (!isset($accounts[$account->id])) { $accounts[$account->id] = [ 'name' => $account->name, - 'balance' => Steam::balance($account,null,true), + 'balance' => Steam::balance($account, null, true), 'leftForPiggyBanks' => $repository->leftOnAccount($account), 'sumOfSaved' => $piggyBank->savedSoFar, 'sumOfTargets' => floatval($piggyBank->targetamount), @@ -326,6 +326,7 @@ class PiggyBankController extends Controller if (intval(Input::get('create_another')) === 1) { Session::put('piggy-banks.create.fromStore', true); + return Redirect::route('piggy-banks.create')->withInput(); } @@ -360,6 +361,7 @@ class PiggyBankController extends Controller if (intval(Input::get('return_to_edit')) === 1) { Session::put('piggy-banks.edit.fromUpdate', true); + return Redirect::route('piggy-banks.edit', $piggyBank->id); } diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 20f24d4d6b..ad6d3e5889 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -11,7 +11,6 @@ use Preferences; use Session; use Steam; use View; -use Crypt; /** * Class ReportController @@ -246,7 +245,7 @@ class ReportController extends Controller /** * Start getExpenseGroupedForMonth DONE */ - $set = $this->query->journalsByExpenseAccount($start, $end, $showSharedReports); + $set = $this->query->journalsByExpenseAccount($start, $end, $showSharedReports); $expenses = Steam::makeArray($set); $expenses = Steam::sortArray($expenses); diff --git a/app/Http/Middleware/PiggyBanks.php b/app/Http/Middleware/PiggyBanks.php index 0854d338a8..8c00cf2376 100644 --- a/app/Http/Middleware/PiggyBanks.php +++ b/app/Http/Middleware/PiggyBanks.php @@ -3,17 +3,13 @@ namespace FireflyIII\Http\Middleware; -use Carbon\Carbon; +use App; use Closure; use FireflyIII\Models\PiggyBank; use FireflyIII\Models\PiggyBankRepetition; use Illuminate\Contracts\Auth\Guard; -use Illuminate\Database\Query\JoinClause; use Illuminate\Http\Request; use Illuminate\Support\Collection; -use Navigation; -use Session; -use App; /** * Class PiggyBanks diff --git a/app/Http/Requests/BudgetFormRequest.php b/app/Http/Requests/BudgetFormRequest.php index 57cd60d20f..452acc42e2 100644 --- a/app/Http/Requests/BudgetFormRequest.php +++ b/app/Http/Requests/BudgetFormRequest.php @@ -30,7 +30,7 @@ class BudgetFormRequest extends Request $nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name,encrypted'; if (Budget::find(Input::get('id'))) { - $nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name,encrypted,'.intval(Input::get('id')); + $nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name,encrypted,' . intval(Input::get('id')); } return [ diff --git a/app/Http/Requests/CategoryFormRequest.php b/app/Http/Requests/CategoryFormRequest.php index 4a074750bd..7c02b57152 100644 --- a/app/Http/Requests/CategoryFormRequest.php +++ b/app/Http/Requests/CategoryFormRequest.php @@ -30,7 +30,7 @@ class CategoryFormRequest extends Request $nameRule = 'required|between:1,100|uniqueObjectForUser:categories,name,encrypted'; if (Category::find(Input::get('id'))) { - $nameRule = 'required|between:1,100|uniqueObjectForUser:categories,name,encrypted,'.intval(Input::get('id')); + $nameRule = 'required|between:1,100|uniqueObjectForUser:categories,name,encrypted,' . intval(Input::get('id')); } return [ diff --git a/app/Http/Requests/PiggyBankFormRequest.php b/app/Http/Requests/PiggyBankFormRequest.php index 2e950b8019..86b9d3ec23 100644 --- a/app/Http/Requests/PiggyBankFormRequest.php +++ b/app/Http/Requests/PiggyBankFormRequest.php @@ -3,9 +3,7 @@ namespace FireflyIII\Http\Requests; use Auth; -use Carbon\Carbon; use Input; -use Navigation; /** * Class PiggyBankFormRequest @@ -32,7 +30,7 @@ class PiggyBankFormRequest extends Request $nameRule = 'required|between:1,255|uniquePiggyBankForUser'; $targetDateRule = 'date'; if (intval(Input::get('id'))) { - $nameRule = 'required|between:1,255|uniquePiggyBankForUser:'.intval(Input::get('id')); + $nameRule = 'required|between:1,255|uniquePiggyBankForUser:' . intval(Input::get('id')); } diff --git a/app/Models/Account.php b/app/Models/Account.php index e95240cdbb..d0c0d7c6cd 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -54,6 +54,7 @@ class Account extends Model App::abort(500, 'Could not create new account with data: ' . json_encode($fields)); } + return $account; } diff --git a/app/Models/Category.php b/app/Models/Category.php index 539f889378..91674b7f87 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -1,8 +1,9 @@ attributes['name'] = Crypt::encrypt($value); $this->attributes['encrypted'] = true; } + /** * @param $value * diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php index c81ef28b71..4b952c1258 100644 --- a/app/Models/PiggyBank.php +++ b/app/Models/PiggyBank.php @@ -1,8 +1,9 @@ attributes['name'] = Crypt::encrypt($value); $this->attributes['encrypted'] = true; } + /** * @param $value * diff --git a/app/Models/Reminder.php b/app/Models/Reminder.php index 62c053d765..b8a62a2383 100644 --- a/app/Models/Reminder.php +++ b/app/Models/Reminder.php @@ -1,9 +1,10 @@ encrypted) == 1) { return json_decode(Crypt::decrypt($value)); } + return json_decode($value); } @@ -90,7 +92,7 @@ class Reminder extends Model public function setMetadataAttribute($value) { $this->attributes['encrypted'] = true; - $this->attributes['metadata'] = Crypt::encrypt(json_encode($value)); + $this->attributes['metadata'] = Crypt::encrypt(json_encode($value)); } /** diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index ab1e04c0be..85f8e74e17 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -1,10 +1,11 @@ reminders()->get(); - /** @var Reminder $reminder */ - foreach($reminders as $reminder) { - $reminder->delete(); + PiggyBank::deleting( + function (PiggyBank $piggyBank) { + $reminders = $piggyBank->reminders()->get(); + /** @var Reminder $reminder */ + foreach ($reminders as $reminder) { + $reminder->delete(); + } } - }); + ); Account::deleted( diff --git a/app/Repositories/Bill/BillRepositoryInterface.php b/app/Repositories/Bill/BillRepositoryInterface.php index 5e6041710b..a6d5c5ea1e 100644 --- a/app/Repositories/Bill/BillRepositoryInterface.php +++ b/app/Repositories/Bill/BillRepositoryInterface.php @@ -89,7 +89,6 @@ interface BillRepositoryInterface public function lastFoundMatch(Bill $bill); - /** * @param Bill $bill * diff --git a/app/Repositories/Journal/JournalRepositoryInterface.php b/app/Repositories/Journal/JournalRepositoryInterface.php index 2bd13b2870..cbe44671a5 100644 --- a/app/Repositories/Journal/JournalRepositoryInterface.php +++ b/app/Repositories/Journal/JournalRepositoryInterface.php @@ -2,8 +2,8 @@ namespace FireflyIII\Repositories\Journal; -use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\Transaction; +use FireflyIII\Models\TransactionJournal; use Illuminate\Support\Collection; /** @@ -48,6 +48,7 @@ interface JournalRepositoryInterface /** * Get users first transaction journal + * * @return TransactionJournal */ public function first(); diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index 3ba63000ab..3dec04fa7e 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -223,10 +223,10 @@ class FireflyValidator extends Validator } $set = $query->get(['piggy_banks.*']); - foreach($set as $entry) { + foreach ($set as $entry) { $isEncrypted = intval($entry->encrypted) == 1 ? true : false; - $checkValue = $isEncrypted ? Crypt::decrypt($entry->name) : $entry->name; - if($checkValue == $value) { + $checkValue = $isEncrypted ? Crypt::decrypt($entry->name) : $entry->name; + if ($checkValue == $value) { return false; } }