mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 02:36:28 +00:00 
			
		
		
		
	Code clean up
This commit is contained in:
		| @@ -11,7 +11,6 @@ declare(strict_types = 1); | ||||
|  | ||||
| namespace FireflyIII\Http\Controllers; | ||||
|  | ||||
| use Auth; | ||||
| use Carbon\Carbon; | ||||
| use ExpandedForm; | ||||
| use FireflyIII\Crud\Account\AccountCrudInterface; | ||||
| @@ -301,7 +300,7 @@ class AccountController extends Controller | ||||
|             'virtualBalance'         => round($request->input('virtualBalance'), 2), | ||||
|             'virtualBalanceCurrency' => intval($request->input('amount_currency_id_virtualBalance')), | ||||
|             'active'                 => true, | ||||
|             'user'                   => Auth::user()->id, | ||||
|             'user'                   => auth()->user()->id, | ||||
|             'iban'                   => $request->input('iban'), | ||||
|             'accountNumber'          => $request->input('accountNumber'), | ||||
|             'accountRole'            => $request->input('accountRole'), | ||||
| @@ -347,7 +346,7 @@ class AccountController extends Controller | ||||
|         $accountData = [ | ||||
|             'name'                   => $request->input('name'), | ||||
|             'active'                 => $request->input('active'), | ||||
|             'user'                   => Auth::user()->id, | ||||
|             'user'                   => auth()->user()->id, | ||||
|             'iban'                   => $request->input('iban'), | ||||
|             'accountNumber'          => $request->input('accountNumber'), | ||||
|             'accountRole'            => $request->input('accountRole'), | ||||
|   | ||||
| @@ -11,7 +11,6 @@ declare(strict_types = 1); | ||||
|  | ||||
| namespace FireflyIII\Http\Controllers\Auth; | ||||
|  | ||||
| use Auth; | ||||
| use FireflyIII\Events\ResendConfirmation; | ||||
| use FireflyIII\Events\UserIsConfirmed; | ||||
| use FireflyIII\Exceptions\FireflyException; | ||||
| @@ -55,10 +54,10 @@ class ConfirmationController extends Controller | ||||
|         if ($database === $code && ($now - $time <= $maxDiff)) { | ||||
|  | ||||
|             // trigger user registration event: | ||||
|             event(new UserIsConfirmed(Auth::user(), $request->ip())); | ||||
|             event(new UserIsConfirmed(auth()->user(), $request->ip())); | ||||
|  | ||||
|             Preferences::setForUser(Auth::user(), 'user_confirmed', true); | ||||
|             Preferences::setForUser(Auth::user(), 'user_confirmed_confirmed', time()); | ||||
|             Preferences::setForUser(auth()->user(), 'user_confirmed', true); | ||||
|             Preferences::setForUser(auth()->user(), 'user_confirmed_confirmed', time()); | ||||
|             Session::flash('success', strval(trans('firefly.account_is_confirmed'))); | ||||
|  | ||||
|             return redirect(route('home')); | ||||
| @@ -79,7 +78,7 @@ class ConfirmationController extends Controller | ||||
|         $owner   = env('SITE_OWNER', 'mail@example.com'); | ||||
|         $view    = 'auth.confirmation.no-resent'; | ||||
|         if ($now - $time > $maxDiff) { | ||||
|             event(new ResendConfirmation(Auth::user(), $request->ip())); | ||||
|             event(new ResendConfirmation(auth()->user(), $request->ip())); | ||||
|             $view = 'auth.confirmation.resent'; | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -11,7 +11,6 @@ declare(strict_types = 1); | ||||
|  | ||||
| namespace FireflyIII\Http\Controllers\Auth; | ||||
|  | ||||
| use Auth; | ||||
| use Carbon\Carbon; | ||||
| use FireflyIII\Exceptions\FireflyException; | ||||
| use FireflyIII\Http\Controllers\Controller; | ||||
| @@ -34,7 +33,7 @@ class TwoFactorController extends Controller | ||||
|      */ | ||||
|     public function index() | ||||
|     { | ||||
|         $user = Auth::user(); | ||||
|         $user = auth()->user(); | ||||
|  | ||||
|         // to make sure the validator in the next step gets the secret, we push it in session | ||||
|         $secret = Preferences::get('twoFactorAuthSecret', '')->data; | ||||
| @@ -54,7 +53,7 @@ class TwoFactorController extends Controller | ||||
|      */ | ||||
|     public function lostTwoFactor() | ||||
|     { | ||||
|         $user      = Auth::user(); | ||||
|         $user      = auth()->user(); | ||||
|         $siteOwner = env('SITE_OWNER', ''); | ||||
|         $title     = strval(trans('firefly.two_factor_forgot_title')); | ||||
|  | ||||
|   | ||||
| @@ -12,7 +12,6 @@ declare(strict_types = 1); | ||||
| namespace FireflyIII\Http\Controllers; | ||||
|  | ||||
| use Amount; | ||||
| use Auth; | ||||
| use Carbon\Carbon; | ||||
| use Config; | ||||
| use FireflyIII\Crud\Account\AccountCrudInterface; | ||||
| @@ -359,7 +358,7 @@ class BudgetController extends Controller | ||||
|     { | ||||
|         $budgetData = [ | ||||
|             'name' => $request->input('name'), | ||||
|             'user' => Auth::user()->id, | ||||
|             'user' => auth()->user()->id, | ||||
|         ]; | ||||
|         $budget     = $repository->store($budgetData); | ||||
|  | ||||
|   | ||||
| @@ -11,7 +11,6 @@ declare(strict_types = 1); | ||||
|  | ||||
| namespace FireflyIII\Http\Controllers; | ||||
|  | ||||
| use Auth; | ||||
| use Carbon\Carbon; | ||||
| use FireflyIII\Crud\Account\AccountCrudInterface; | ||||
| use FireflyIII\Http\Requests\CategoryFormRequest; | ||||
| @@ -265,7 +264,7 @@ class CategoryController extends Controller | ||||
|     { | ||||
|         $categoryData = [ | ||||
|             'name' => $request->input('name'), | ||||
|             'user' => Auth::user()->id, | ||||
|             'user' => auth()->user()->id, | ||||
|         ]; | ||||
|         $category     = $repository->store($categoryData); | ||||
|  | ||||
|   | ||||
| @@ -11,7 +11,6 @@ declare(strict_types = 1); | ||||
|  | ||||
| namespace FireflyIII\Http\Controllers; | ||||
|  | ||||
| use Auth; | ||||
| use Cache; | ||||
| use FireflyIII\Http\Requests\CurrencyFormRequest; | ||||
| use FireflyIII\Models\TransactionCurrency; | ||||
| @@ -119,7 +118,7 @@ class CurrencyController extends Controller | ||||
|         } | ||||
|  | ||||
|         Session::flash('success', trans('firefly.deleted_currency', ['name' => $currency->name])); | ||||
|         if (Auth::user()->hasRole('owner')) { | ||||
|         if (auth()->user()->hasRole('owner')) { | ||||
|             $currency->delete(); | ||||
|         } | ||||
|  | ||||
| @@ -160,7 +159,7 @@ class CurrencyController extends Controller | ||||
|         $defaultCurrency = $repository->getCurrencyByPreference(Preferences::get('currencyPreference', env('DEFAULT_CURRENCY', 'EUR'))); | ||||
|  | ||||
|  | ||||
|         if (!Auth::user()->hasRole('owner')) { | ||||
|         if (!auth()->user()->hasRole('owner')) { | ||||
|             Session::flash('warning', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')])); | ||||
|         } | ||||
|  | ||||
| @@ -177,8 +176,8 @@ class CurrencyController extends Controller | ||||
|      */ | ||||
|     public function store(CurrencyFormRequest $request, CurrencyRepositoryInterface $repository) | ||||
|     { | ||||
|         if (!Auth::user()->hasRole('owner')) { | ||||
|             Log::error('User ' . Auth::user()->id . ' is not admin, but tried to store a currency.'); | ||||
|         if (!auth()->user()->hasRole('owner')) { | ||||
|             Log::error('User ' . auth()->user()->id . ' is not admin, but tried to store a currency.'); | ||||
|  | ||||
|             return redirect(session('currency.create.url')); | ||||
|         } | ||||
| @@ -209,7 +208,7 @@ class CurrencyController extends Controller | ||||
|     public function update(CurrencyFormRequest $request, CurrencyRepositoryInterface $repository, TransactionCurrency $currency) | ||||
|     { | ||||
|         $data = $request->getCurrencyData(); | ||||
|         if (Auth::user()->hasRole('owner')) { | ||||
|         if (auth()->user()->hasRole('owner')) { | ||||
|             $currency = $repository->update($currency, $data); | ||||
|         } | ||||
|         Session::flash('success', trans('firefly.updated_currency', ['name' => $currency->name])); | ||||
|   | ||||
| @@ -10,7 +10,6 @@ | ||||
| declare(strict_types = 1); | ||||
| namespace FireflyIII\Http\Controllers; | ||||
|  | ||||
| use Auth; | ||||
| use Carbon\Carbon; | ||||
| use FireflyIII\Crud\Account\AccountCrudInterface; | ||||
| use FireflyIII\Http\Requests\NewUserFormRequest; | ||||
| @@ -107,7 +106,7 @@ class NewUserController extends Controller | ||||
|             'accountType'            => 'asset', | ||||
|             'virtualBalance'         => 0, | ||||
|             'active'                 => true, | ||||
|             'user'                   => Auth::user()->id, | ||||
|             'user'                   => auth()->user()->id, | ||||
|             'accountRole'            => 'defaultAsset', | ||||
|             'openingBalance'         => round($request->input('bank_balance'), 2), | ||||
|             'openingBalanceDate'     => new Carbon, | ||||
| @@ -133,7 +132,7 @@ class NewUserController extends Controller | ||||
|             'accountType'            => 'asset', | ||||
|             'virtualBalance'         => 0, | ||||
|             'active'                 => true, | ||||
|             'user'                   => Auth::user()->id, | ||||
|             'user'                   => auth()->user()->id, | ||||
|             'accountRole'            => 'savingAsset', | ||||
|             'openingBalance'         => round($request->input('savings_balance'), 2), | ||||
|             'openingBalanceDate'     => new Carbon, | ||||
| @@ -158,7 +157,7 @@ class NewUserController extends Controller | ||||
|             'accountType'            => 'asset', | ||||
|             'virtualBalance'         => round($request->get('credit_card_limit'), 2), | ||||
|             'active'                 => true, | ||||
|             'user'                   => Auth::user()->id, | ||||
|             'user'                   => auth()->user()->id, | ||||
|             'accountRole'            => 'ccAsset', | ||||
|             'openingBalance'         => null, | ||||
|             'openingBalanceDate'     => null, | ||||
|   | ||||
| @@ -10,7 +10,6 @@ | ||||
| declare(strict_types = 1); | ||||
| namespace FireflyIII\Http\Controllers; | ||||
|  | ||||
| use Auth; | ||||
| use FireflyIII\Crud\Account\AccountCrudInterface; | ||||
| use FireflyIII\Http\Requests\TokenFormRequest; | ||||
| use FireflyIII\Models\AccountType; | ||||
| @@ -47,7 +46,7 @@ class PreferencesController extends Controller | ||||
|     { | ||||
|         $domain = $this->getDomain(); | ||||
|         /** @noinspection PhpMethodParametersCountMismatchInspection */ | ||||
|         $secret = $google2fa->generateSecretKey(16, Auth::user()->id); | ||||
|         $secret = $google2fa->generateSecretKey(16, auth()->user()->id); | ||||
|         Session::flash('two-factor-secret', $secret); | ||||
|         $image = $google2fa->getQRCodeInline('Firefly III at ' . $domain, null, $secret, 150); | ||||
|  | ||||
|   | ||||
| @@ -11,7 +11,6 @@ declare(strict_types = 1); | ||||
|  | ||||
| namespace FireflyIII\Http\Controllers; | ||||
|  | ||||
| use Auth; | ||||
| use FireflyIII\Events\UserIsDeleted; | ||||
| use FireflyIII\Http\Requests\DeleteAccountFormRequest; | ||||
| use FireflyIII\Http\Requests\ProfileFormRequest; | ||||
| @@ -41,7 +40,7 @@ class ProfileController extends Controller | ||||
|      */ | ||||
|     public function changePassword() | ||||
|     { | ||||
|         return view('profile.change-password')->with('title', Auth::user()->email)->with('subTitle', trans('firefly.change_your_password'))->with( | ||||
|         return view('profile.change-password')->with('title', auth()->user()->email)->with('subTitle', trans('firefly.change_your_password'))->with( | ||||
|             'mainTitleIcon', 'fa-user' | ||||
|         ); | ||||
|     } | ||||
| @@ -51,7 +50,7 @@ class ProfileController extends Controller | ||||
|      */ | ||||
|     public function deleteAccount() | ||||
|     { | ||||
|         return view('profile.delete-account')->with('title', Auth::user()->email)->with('subTitle', trans('firefly.delete_account'))->with( | ||||
|         return view('profile.delete-account')->with('title', auth()->user()->email)->with('subTitle', trans('firefly.delete_account'))->with( | ||||
|             'mainTitleIcon', 'fa-user' | ||||
|         ); | ||||
|     } | ||||
| @@ -62,7 +61,7 @@ class ProfileController extends Controller | ||||
|      */ | ||||
|     public function index() | ||||
|     { | ||||
|         return view('profile.index')->with('title', trans('firefly.profile'))->with('subTitle', Auth::user()->email)->with('mainTitleIcon', 'fa-user'); | ||||
|         return view('profile.index')->with('title', trans('firefly.profile'))->with('subTitle', auth()->user()->email)->with('mainTitleIcon', 'fa-user'); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -73,7 +72,7 @@ class ProfileController extends Controller | ||||
|     public function postChangePassword(ProfileFormRequest $request) | ||||
|     { | ||||
|         // old, new1, new2 | ||||
|         if (!Hash::check($request->get('current_password'), Auth::user()->password)) { | ||||
|         if (!Hash::check($request->get('current_password'), auth()->user()->password)) { | ||||
|             Session::flash('error', strval(trans('firefly.invalid_current_password'))); | ||||
|  | ||||
|             return redirect(route('profile.change-password')); | ||||
| @@ -86,8 +85,8 @@ class ProfileController extends Controller | ||||
|         } | ||||
|  | ||||
|         // update the user with the new password. | ||||
|         Auth::user()->password = bcrypt($request->get('new_password')); | ||||
|         Auth::user()->save(); | ||||
|         auth()->user()->password = bcrypt($request->get('new_password')); | ||||
|         auth()->user()->save(); | ||||
|  | ||||
|         Session::flash('success', strval(trans('firefly.password_changed'))); | ||||
|  | ||||
| @@ -103,22 +102,22 @@ class ProfileController extends Controller | ||||
|     public function postDeleteAccount(DeleteAccountFormRequest $request) | ||||
|     { | ||||
|         // old, new1, new2 | ||||
|         if (!Hash::check($request->get('password'), Auth::user()->password)) { | ||||
|         if (!Hash::check($request->get('password'), auth()->user()->password)) { | ||||
|             Session::flash('error', strval(trans('firefly.invalid_password'))); | ||||
|  | ||||
|             return redirect(route('profile.delete-account')); | ||||
|         } | ||||
|  | ||||
|         // respond to deletion: | ||||
|         event(new UserIsDeleted(Auth::user(), $request->ip())); | ||||
|         event(new UserIsDeleted(auth()->user(), $request->ip())); | ||||
|  | ||||
|         // store some stuff for the future: | ||||
|         $registration = Preferences::get('registration_ip_address')->data; | ||||
|         $confirmation = Preferences::get('confirmation_ip_address')->data; | ||||
|  | ||||
|         // DELETE! | ||||
|         $email = Auth::user()->email; | ||||
|         Auth::user()->delete(); | ||||
|         $email = auth()->user()->email; | ||||
|         auth()->user()->delete(); | ||||
|         Session::flush(); | ||||
|         Session::flash('gaEventCategory', 'user'); | ||||
|         Session::flash('gaEventAction', 'delete-account'); | ||||
|   | ||||
| @@ -11,7 +11,6 @@ declare(strict_types = 1); | ||||
|  | ||||
| namespace FireflyIII\Http\Controllers; | ||||
|  | ||||
| use Auth; | ||||
| use FireflyIII\Http\Requests\RuleFormRequest; | ||||
| use FireflyIII\Http\Requests\TestRuleFormRequest; | ||||
| use FireflyIII\Models\Rule; | ||||
| @@ -189,7 +188,7 @@ class RuleController extends Controller | ||||
|     { | ||||
|         $this->createDefaultRuleGroup(); | ||||
|         $this->createDefaultRule(); | ||||
|         $ruleGroups = $repository->getRuleGroupsWithRules(Auth::user()); | ||||
|         $ruleGroups = $repository->getRuleGroupsWithRules(auth()->user()); | ||||
|  | ||||
|         return view('rules.index', compact('ruleGroups')); | ||||
|     } | ||||
| @@ -243,7 +242,7 @@ class RuleController extends Controller | ||||
|         $data = [ | ||||
|             'rule_group_id'       => $ruleGroup->id, | ||||
|             'title'               => $request->get('title'), | ||||
|             'user_id'             => Auth::user()->id, | ||||
|             'user_id'             => auth()->user()->id, | ||||
|             'trigger'             => $request->get('trigger'), | ||||
|             'description'         => $request->get('description'), | ||||
|             'rule-triggers'       => $request->get('rule-trigger'), | ||||
| @@ -380,7 +379,7 @@ class RuleController extends Controller | ||||
|             $data = [ | ||||
|                 'rule_group_id'       => $repository->getFirstRuleGroup()->id, | ||||
|                 'stop_processing'     => 0, | ||||
|                 'user_id'             => Auth::user()->id, | ||||
|                 'user_id'             => auth()->user()->id, | ||||
|                 'title'               => trans('firefly.default_rule_name'), | ||||
|                 'description'         => trans('firefly.default_rule_description'), | ||||
|                 'trigger'             => 'store-journal', | ||||
| @@ -413,7 +412,7 @@ class RuleController extends Controller | ||||
|  | ||||
|         if ($repository->count() === 0) { | ||||
|             $data = [ | ||||
|                 'user_id'     => Auth::user()->id, | ||||
|                 'user_id'     => auth()->user()->id, | ||||
|                 'title'       => trans('firefly.default_rule_group_name'), | ||||
|                 'description' => trans('firefly.default_rule_group_description'), | ||||
|             ]; | ||||
|   | ||||
| @@ -11,7 +11,6 @@ declare(strict_types = 1); | ||||
|  | ||||
| namespace FireflyIII\Http\Controllers; | ||||
|  | ||||
| use Auth; | ||||
| use Carbon\Carbon; | ||||
| use ExpandedForm; | ||||
| use FireflyIII\Crud\Account\AccountCrudInterface; | ||||
| @@ -96,7 +95,7 @@ class RuleGroupController extends Controller | ||||
|     { | ||||
|  | ||||
|         $title  = $ruleGroup->title; | ||||
|         $moveTo = Auth::user()->ruleGroups()->find(intval(Input::get('move_rules_before_delete'))); | ||||
|         $moveTo = auth()->user()->ruleGroups()->find(intval(Input::get('move_rules_before_delete'))); | ||||
|  | ||||
|         $repository->destroy($ruleGroup, $moveTo); | ||||
|  | ||||
| @@ -163,7 +162,7 @@ class RuleGroupController extends Controller | ||||
|         $job = new ExecuteRuleGroupOnExistingTransactions($ruleGroup); | ||||
|  | ||||
|         // Apply parameters to the job | ||||
|         $job->setUser(Auth::user()); | ||||
|         $job->setUser(auth()->user()); | ||||
|         $job->setAccounts($accounts); | ||||
|         $job->setStartDate($startDate); | ||||
|         $job->setEndDate($endDate); | ||||
| @@ -207,7 +206,7 @@ class RuleGroupController extends Controller | ||||
|         $data = [ | ||||
|             'title'       => $request->input('title'), | ||||
|             'description' => $request->input('description'), | ||||
|             'user_id'     => Auth::user()->id, | ||||
|             'user_id'     => auth()->user()->id, | ||||
|         ]; | ||||
|  | ||||
|         $ruleGroup = $repository->store($data); | ||||
|   | ||||
| @@ -11,7 +11,6 @@ declare(strict_types = 1); | ||||
|  | ||||
| namespace FireflyIII\Http\Controllers; | ||||
|  | ||||
| use Auth; | ||||
| use FireflyIII\Http\Requests\TagFormRequest; | ||||
| use FireflyIII\Models\Preference; | ||||
| use FireflyIII\Models\Tag; | ||||
| @@ -194,7 +193,7 @@ class TagController extends Controller | ||||
|         foreach ($types as $type) { | ||||
|  | ||||
|             /** @var Collection $tags */ | ||||
|             $tags = Auth::user()->tags()->where('tagMode', $type)->orderBy('date', 'ASC')->get(); | ||||
|             $tags = auth()->user()->tags()->where('tagMode', $type)->orderBy('date', 'ASC')->get(); | ||||
|             $tags = $tags->sortBy( | ||||
|                 function (Tag $tag) { | ||||
|                     $date = !is_null($tag->date) ? $tag->date->format('Ymd') : '000000'; | ||||
|   | ||||
| @@ -11,7 +11,6 @@ declare(strict_types = 1); | ||||
|  | ||||
| namespace FireflyIII\Http\Controllers\Transaction; | ||||
|  | ||||
| use Auth; | ||||
| use Carbon\Carbon; | ||||
| use ExpandedForm; | ||||
| use FireflyIII\Http\Controllers\Controller; | ||||
| @@ -205,7 +204,7 @@ class MassController extends Controller | ||||
|                         'destination_account_id'    => $sourceAccountName, | ||||
|                         'destination_account_name'  => $destAccountName, | ||||
|                         'amount'                    => round($request->get('amount')[$journal->id], 4), | ||||
|                         'user'                      => Auth::user()->id, | ||||
|                         'user'                      => auth()->user()->id, | ||||
|                         'amount_currency_id_amount' => intval($request->get('amount_currency_id_amount_' . $journal->id)), | ||||
|                         'date'                      => new Carbon($request->get('date')[$journal->id]), | ||||
|                         'interest_date'             => $journal->interest_date, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user