Code clean up

This commit is contained in:
James Cole 2016-09-16 12:15:58 +02:00
parent f38984398d
commit d25d0454fc
52 changed files with 135 additions and 185 deletions

View File

@ -10,7 +10,6 @@
declare(strict_types = 1);
namespace FireflyIII\Exceptions;
use Auth;
use ErrorException;
use Exception;
use FireflyIII\Jobs\MailError;
@ -82,8 +81,8 @@ class Handler extends ExceptionHandler
'email' => 'unknown@example.com',
];
if (auth()->check()) {
$userData['id'] = Auth::user()->id;
$userData['email'] = Auth::user()->email;
$userData['id'] = auth()->user()->id;
$userData['email'] = auth()->user()->email;
}
$data = [
'class' => get_class($exception),

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Export\Collector;
use Auth;
use Crypt;
use FireflyIII\Models\ExportJob;
use Illuminate\Contracts\Encryption\DecryptException;
@ -50,7 +49,7 @@ class UploadCollector extends BasicCollector implements CollectorInterface
$this->exportDisk = Storage::disk('export');
// file names associated with the old import routine.
$this->expected = 'csv-upload-' . Auth::user()->id . '-';
$this->expected = 'csv-upload-' . auth()->user()->id . '-';
// for the new import routine:
$this->getImportKeys();
@ -76,7 +75,7 @@ class UploadCollector extends BasicCollector implements CollectorInterface
*/
private function getImportKeys()
{
$set = Auth::user()->importJobs()->where('status', 'import_complete')->get(['import_jobs.*']);
$set = auth()->user()->importJobs()->where('status', 'import_complete')->get(['import_jobs.*']);
if ($set->count() > 0) {
$keys = $set->pluck('key')->toArray();
$this->importKeys = $keys;
@ -158,7 +157,7 @@ class UploadCollector extends BasicCollector implements CollectorInterface
{
// find job associated with import file:
$name = str_replace('.upload', '', $entry);
$job = Auth::user()->importJobs()->where('key', $name)->first();
$job = auth()->user()->importJobs()->where('key', $name)->first();
$content = '';
try {
$content = Crypt::decrypt($this->uploadDisk->get($entry));

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Handlers\Events;
use Auth;
use FireflyIII\Events\TransactionJournalStored;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankEvent;
@ -39,7 +38,7 @@ class ConnectJournalToPiggyBank
$piggyBankId = $event->piggyBankId;
/** @var PiggyBank $piggyBank */
$piggyBank = Auth::user()->piggyBanks()->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*']);
$piggyBank = auth()->user()->piggyBanks()->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*']);
if (is_null($piggyBank)) {
return true;

View File

@ -17,7 +17,6 @@ use FireflyIII\Models\Rule;
use FireflyIII\Models\RuleGroup;
use FireflyIII\Rules\Processor;
use FireflyIII\User;
use Illuminate\Support\Facades\Auth;
/**
* Class FireRulesForStore
@ -38,7 +37,7 @@ class FireRulesForStore
{
// get all the user's rule groups, with the rules, order by 'order'.
/** @var User $user */
$user = Auth::user();
$user = auth()->user();
$groups = $user->ruleGroups()->where('rule_groups.active', 1)->orderBy('order', 'ASC')->get();
//
/** @var RuleGroup $group */

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Handlers\Events;
use Auth;
use FireflyIII\Events\TransactionJournalUpdated;
use FireflyIII\Models\Rule;
use FireflyIII\Models\RuleGroup;
@ -36,7 +35,7 @@ class FireRulesForUpdate
{
// get all the user's rule groups, with the rules, order by 'order'.
/** @var User $user */
$user = Auth::user();
$user = auth()->user();
$groups = $user->ruleGroups()->where('rule_groups.active', 1)->orderBy('order', 'ASC')->get();
//
/** @var RuleGroup $group */

View File

@ -10,7 +10,6 @@
declare(strict_types = 1);
namespace FireflyIII\Helpers\Attachments;
use Auth;
use Crypt;
use FireflyIII\Models\Attachment;
use Illuminate\Database\Eloquent\Model;
@ -112,7 +111,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$md5 = md5_file($file->getRealPath());
$name = $file->getClientOriginalName();
$class = get_class($model);
$count = Auth::user()->attachments()->where('md5', $md5)->where('attachable_id', $model->id)->where('attachable_type', $class)->count();
$count = auth()->user()->attachments()->where('md5', $md5)->where('attachable_id', $model->id)->where('attachable_type', $class)->count();
if ($count > 0) {
$msg = (string)trans('validation.file_already_attached', ['name' => $name]);
@ -139,7 +138,7 @@ class AttachmentHelper implements AttachmentHelperInterface
}
$attachment = new Attachment; // create Attachment object.
$attachment->user()->associate(Auth::user());
$attachment->user()->associate(auth()->user());
$attachment->attachable()->associate($model);
$attachment->md5 = md5_file($file->getRealPath());
$attachment->filename = $file->getClientOriginalName();

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Helpers\Report;
use Auth;
use Carbon\Carbon;
use DB;
use FireflyIII\Helpers\Collection\Balance;
@ -102,34 +101,34 @@ class BalanceReportHelper implements BalanceReportHelperInterface
private function allCoveredByBalancingActs(Collection $accounts, Carbon $start, Carbon $end): Collection
{
$ids = $accounts->pluck('id')->toArray();
$set = Auth::user()->tags()
->leftJoin('tag_transaction_journal', 'tag_transaction_journal.tag_id', '=', 'tags.id')
->leftJoin('transaction_journals', 'tag_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id')
->leftJoin(
'transactions AS t_source', function (JoinClause $join) {
$join->on('transaction_journals.id', '=', 't_source.transaction_journal_id')->where('t_source.amount', '<', 0);
}
)
->leftJoin(
'transactions AS t_destination', function (JoinClause $join) {
$join->on('transaction_journals.id', '=', 't_destination.transaction_journal_id')->where('t_destination.amount', '>', 0);
}
)
->where('tags.tagMode', 'balancingAct')
->where('transaction_types.type', TransactionType::TRANSFER)
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
->whereNull('transaction_journals.deleted_at')
->whereIn('t_source.account_id', $ids)
->whereIn('t_destination.account_id', $ids)
->groupBy('t_destination.account_id')
->get(
[
't_destination.account_id',
DB::raw('SUM(`t_destination`.`amount`) as `sum`'),
]
);
$set = auth()->user()->tags()
->leftJoin('tag_transaction_journal', 'tag_transaction_journal.tag_id', '=', 'tags.id')
->leftJoin('transaction_journals', 'tag_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id')
->leftJoin(
'transactions AS t_source', function (JoinClause $join) {
$join->on('transaction_journals.id', '=', 't_source.transaction_journal_id')->where('t_source.amount', '<', 0);
}
)
->leftJoin(
'transactions AS t_destination', function (JoinClause $join) {
$join->on('transaction_journals.id', '=', 't_destination.transaction_journal_id')->where('t_destination.amount', '>', 0);
}
)
->where('tags.tagMode', 'balancingAct')
->where('transaction_types.type', TransactionType::TRANSFER)
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
->whereNull('transaction_journals.deleted_at')
->whereIn('t_source.account_id', $ids)
->whereIn('t_destination.account_id', $ids)
->groupBy('t_destination.account_id')
->get(
[
't_destination.account_id',
DB::raw('SUM(`t_destination`.`amount`) as `sum`'),
]
);
return $set;
}

View File

@ -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'),

View File

@ -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';
}

View File

@ -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'));

View File

@ -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);

View File

@ -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);

View File

@ -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]));

View File

@ -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,

View File

@ -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);

View File

@ -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');

View File

@ -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'),
];

View File

@ -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);

View File

@ -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';

View File

@ -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,

View File

@ -41,7 +41,7 @@ class Authenticate
return redirect()->guest('login');
}
if (intval(Auth::user()->blocked) === 1) {
if (intval(auth()->user()->blocked) === 1) {
Auth::guard($guard)->logout();
Session::flash('logoutMessage', trans('firefly.block_account_logout'));

View File

@ -45,7 +45,7 @@ class AuthenticateTwoFactor
return redirect()->guest('login');
}
if (intval(Auth::user()->blocked) === 1) {
if (intval(auth()->user()->blocked) === 1) {
Auth::guard($guard)->logout();
Session::flash('logoutMessage', trans('firefly.block_account_logout'));

View File

@ -43,7 +43,7 @@ class IsAdmin
return redirect()->guest('login');
}
/** @var User $user */
$user = Auth::user();
$user = auth()->user();
if (!$user->hasRole('owner')) {
return redirect(route('home'));
}

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Http\Requests;
use Auth;
use Carbon\Carbon;
use Input;
@ -45,7 +44,7 @@ class BillFormRequest extends Request
'amount_currency_id_amount_max' => intval($this->get('amount_currency_id_amount_max')),
'amount_max' => round($this->get('amount_max'), 2),
'date' => new Carbon($this->get('date')),
'user' => Auth::user()->id,
'user' => auth()->user()->id,
'repeat_freq' => $this->get('repeat_freq'),
'skip' => intval($this->get('skip')),
'automatch' => intval($this->get('automatch')) === 1,

View File

@ -11,8 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Http\Requests;
use Auth;
/**
* Class ConfigurationRequest
*
@ -27,7 +25,7 @@ class ConfigurationRequest extends Request
public function authorize()
{
// Only allow logged in users and admins
return auth()->check() && Auth::user()->hasRole('owner');
return auth()->check() && auth()->user()->hasRole('owner');
}
/**

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Http\Requests;
use Auth;
use Carbon\Carbon;
use Exception;
use FireflyIII\Exceptions\FireflyException;
@ -50,7 +49,7 @@ class JournalFormRequest extends Request
'destination_account_id' => intval($this->get('destination_account_id')),
'destination_account_name' => $this->get('destination_account_name') ?? '',
'amount' => round($this->get('amount'), 2),
'user' => Auth::user()->id,
'user' => auth()->user()->id,
'amount_currency_id_amount' => intval($this->get('amount_currency_id_amount')),
'date' => new Carbon($this->get('date')),
'interest_date' => $this->get('interest_date') ? new Carbon($this->get('interest_date')) : null,

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Models;
use Auth;
use Crypt;
use FireflyIII\Exceptions\FireflyException;
use Illuminate\Contracts\Encryption\DecryptException;
@ -154,7 +153,7 @@ class Account extends Model
{
if (auth()->check()) {
if ($value->user_id == Auth::user()->id) {
if ($value->user_id == auth()->user()->id) {
return $value;
}
}

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Models;
use Auth;
use Crypt;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@ -71,7 +70,7 @@ class Attachment extends Model
{
if (auth()->check()) {
if ($value->user_id == Auth::user()->id) {
if ($value->user_id == auth()->user()->id) {
return $value;
}
}

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Models;
use Auth;
use Crypt;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@ -82,7 +81,7 @@ class Bill extends Model
public static function routeBinder(Bill $value)
{
if (auth()->check()) {
if ($value->user_id == Auth::user()->id) {
if ($value->user_id == auth()->user()->id) {
return $value;
}
}

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Models;
use Auth;
use Crypt;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@ -95,7 +94,7 @@ class Budget extends Model
public static function routeBinder(Budget $value)
{
if (auth()->check()) {
if ($value->user_id == Auth::user()->id) {
if ($value->user_id == auth()->user()->id) {
return $value;
}
}

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Models;
use Auth;
use Crypt;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@ -90,7 +89,7 @@ class Category extends Model
public static function routeBinder(Category $value)
{
if (auth()->check()) {
if ($value->user_id == Auth::user()->id) {
if ($value->user_id == auth()->user()->id) {
return $value;
}
}

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Models;
use Auth;
use Illuminate\Database\Eloquent\Model;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@ -45,7 +44,7 @@ class ExportJob extends Model
public static function routeBinder($value)
{
if (auth()->check()) {
$model = self::where('key', $value)->where('user_id', Auth::user()->id)->first();
$model = self::where('key', $value)->where('user_id', auth()->user()->id)->first();
if (!is_null($model)) {
return $model;
}

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Models;
use Auth;
use Crypt;
use Illuminate\Database\Eloquent\Model;
use Storage;
@ -63,7 +62,7 @@ class ImportJob extends Model
public static function routeBinder($value)
{
if (auth()->check()) {
$model = self::where('key', $value)->where('user_id', Auth::user()->id)->first();
$model = self::where('key', $value)->where('user_id', auth()->user()->id)->first();
if (!is_null($model)) {
return $model;
}

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Models;
use Auth;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
@ -58,7 +57,7 @@ class LimitRepetition extends Model
$object = LimitRepetition::where('limit_repetitions.id', $value)
->leftJoin('budget_limits', 'budget_limits.id', '=', 'limit_repetitions.budget_limit_id')
->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
->where('budgets.user_id', Auth::user()->id)
->where('budgets.user_id', auth()->user()->id)
->first(['limit_repetitions.*']);
if ($object) {
return $object;

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Models;
use Auth;
use Crypt;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@ -71,7 +70,7 @@ class PiggyBank extends Model
public static function routeBinder(PiggyBank $value)
{
if (auth()->check()) {
if ($value->account->user_id == Auth::user()->id) {
if ($value->account->user_id == auth()->user()->id) {
return $value;
}
}

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Models;
use Auth;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@ -60,7 +59,7 @@ class Rule extends Model
public static function routeBinder(Rule $value)
{
if (auth()->check()) {
if ($value->user_id == Auth::user()->id) {
if ($value->user_id == auth()->user()->id) {
return $value;
}
}

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Models;
use Auth;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@ -56,7 +55,7 @@ class RuleGroup extends Model
public static function routeBinder(RuleGroup $value)
{
if (auth()->check()) {
if ($value->user_id == Auth::user()->id) {
if ($value->user_id == auth()->user()->id) {
return $value;
}
}

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Models;
use Auth;
use Crypt;
use FireflyIII\Support\Models\TagSupport;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@ -97,7 +96,7 @@ class Tag extends TagSupport
public static function routeBinder(Tag $value)
{
if (auth()->check()) {
if ($value->user_id == Auth::user()->id) {
if ($value->user_id == auth()->user()->id) {
return $value;
}
}

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Models;
use Auth;
use Carbon\Carbon;
use Crypt;
use FireflyIII\Support\CacheProperties;
@ -133,7 +132,7 @@ class TransactionJournal extends TransactionJournalSupport
$object = TransactionJournal::where('transaction_journals.id', $value)
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->whereIn('transaction_types.type', $validTypes)
->where('user_id', Auth::user()->id)->first(['transaction_journals.*']);
->where('user_id', auth()->user()->id)->first(['transaction_journals.*']);
if ($object) {
return $object;
}

View File

@ -12,7 +12,6 @@ declare(strict_types = 1);
namespace FireflyIII\Support\Binder;
use Auth;
use FireflyIII\Models\Account;
use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@ -43,7 +42,7 @@ class AccountList implements BinderInterface
/** @var \Illuminate\Support\Collection $object */
$object = Account::leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->whereIn('accounts.id', $ids)
->where('user_id', Auth::user()->id)
->where('user_id', auth()->user()->id)
->get(['accounts.*']);
if ($object->count() > 0) {
return $object;

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Support\Binder;
use Auth;
use FireflyIII\Models\Budget;
use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@ -38,7 +37,7 @@ class BudgetList implements BinderInterface
/** @var \Illuminate\Support\Collection $object */
$object = Budget::where('active', 1)
->whereIn('id', $ids)
->where('user_id', Auth::user()->id)
->where('user_id', auth()->user()->id)
->get();
// add empty budget if applicable.

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Support\Binder;
use Auth;
use FireflyIII\Models\Category;
use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@ -36,7 +35,7 @@ class CategoryList implements BinderInterface
$ids = explode(',', $value);
/** @var \Illuminate\Support\Collection $object */
$object = Category::whereIn('id', $ids)
->where('user_id', Auth::user()->id)
->where('user_id', auth()->user()->id)
->get();
// add empty category if applicable.

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Support\Binder;
use Auth;
use Carbon\Carbon;
use Exception;
use FireflyIII\Helpers\FiscalHelper;
@ -42,7 +41,7 @@ class Date implements BinderInterface
try {
$date = new Carbon($value);
} catch (Exception $e) {
Log::error('Could not parse date "' . $value . '" for user #' . Auth::user()->id);
Log::error('Could not parse date "' . $value . '" for user #' . auth()->user()->id);
throw new NotFoundHttpException;
}

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Support\Binder;
use Auth;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@ -37,7 +36,7 @@ class JournalList implements BinderInterface
/** @var \Illuminate\Support\Collection $object */
$object = TransactionJournal::whereIn('transaction_journals.id', $ids)
->expanded()
->where('transaction_journals.user_id', Auth::user()->id)
->where('transaction_journals.user_id', auth()->user()->id)
->get(TransactionJournal::queryFields());
if ($object->count() > 0) {

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Support\Binder;
use Auth;
use FireflyIII\Models\TransactionJournal;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@ -36,7 +35,7 @@ class UnfinishedJournal implements BinderInterface
$object = TransactionJournal::where('transaction_journals.id', $value)
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->where('completed', 0)
->where('user_id', Auth::user()->id)->first(['transaction_journals.*']);
->where('user_id', auth()->user()->id)->first(['transaction_journals.*']);
if ($object) {
return $object;
}

View File

@ -12,7 +12,6 @@ declare(strict_types = 1);
namespace FireflyIII\Support;
use Auth;
use Cache;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
@ -39,7 +38,7 @@ class CacheProperties
{
$this->properties = new Collection;
if (auth()->check()) {
$this->addProperty(Auth::user()->id);
$this->addProperty(auth()->user()->id);
$this->addProperty(Prefs::lastActivity());
}
}

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Support;
use Auth;
use Cache;
use FireflyIII\Models\Configuration;
use FireflyIII\Models\Preference;
@ -32,11 +31,11 @@ class FireflyConfig
*/
public function delete($name): bool
{
$fullName = 'preference' . Auth::user()->id . $name;
$fullName = 'preference' . auth()->user()->id . $name;
if (Cache::has($fullName)) {
Cache::forget($fullName);
}
Preference::where('user_id', Auth::user()->id)->where('name', $name)->delete();
Preference::where('user_id', auth()->user()->id)->where('name', $name)->delete();
return true;
}

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Support;
use Auth;
use Cache;
use FireflyIII\Models\Preference;
use FireflyIII\User;
@ -31,11 +30,11 @@ class Preferences
*/
public function delete($name): bool
{
$fullName = 'preference' . Auth::user()->id . $name;
$fullName = 'preference' . auth()->user()->id . $name;
if (Cache::has($fullName)) {
Cache::forget($fullName);
}
Preference::where('user_id', Auth::user()->id)->where('name', $name)->delete();
Preference::where('user_id', auth()->user()->id)->where('name', $name)->delete();
return true;
}
@ -48,12 +47,12 @@ class Preferences
*/
public function get($name, $default = null)
{
$user = Auth::user();
$user = auth()->user();
if (is_null($user)) {
return $default;
}
return $this->getForUser(Auth::user(), $name, $default);
return $this->getForUser(auth()->user(), $name, $default);
}
/**
@ -115,7 +114,7 @@ class Preferences
*/
public function set($name, $value): Preference
{
$user = Auth::user();
$user = auth()->user();
if (is_null($user)) {
// make new preference, return it:
$pref = new Preference;
@ -125,7 +124,7 @@ class Preferences
return $pref;
}
return $this->setForUser(Auth::user(), $name, $value);
return $this->setForUser(auth()->user(), $name, $value);
}
/**

View File

@ -12,7 +12,6 @@ declare(strict_types = 1);
namespace FireflyIII\Support\Search;
use Auth;
use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
use FireflyIII\Models\TransactionJournal;
@ -33,7 +32,7 @@ class Search implements SearchInterface
*/
public function searchAccounts(array $words): Collection
{
return Auth::user()->accounts()->with('accounttype')->where(
return auth()->user()->accounts()->with('accounttype')->where(
function (EloquentBuilder $q) use ($words) {
foreach ($words as $word) {
$q->orWhere('name', 'LIKE', '%' . e($word) . '%');
@ -50,7 +49,7 @@ class Search implements SearchInterface
public function searchBudgets(array $words): Collection
{
/** @var Collection $set */
$set = Auth::user()->budgets()->get();
$set = auth()->user()->budgets()->get();
$newSet = $set->filter(
function (Budget $b) use ($words) {
$found = 0;
@ -75,7 +74,7 @@ class Search implements SearchInterface
public function searchCategories(array $words): Collection
{
/** @var Collection $set */
$set = Auth::user()->categories()->get();
$set = auth()->user()->categories()->get();
$newSet = $set->filter(
function (Category $c) use ($words) {
$found = 0;
@ -111,7 +110,7 @@ class Search implements SearchInterface
public function searchTransactions(array $words): Collection
{
// decrypted transaction journals:
$decrypted = Auth::user()->transactionJournals()->expanded()->where('transaction_journals.encrypted', 0)->where(
$decrypted = auth()->user()->transactionJournals()->expanded()->where('transaction_journals.encrypted', 0)->where(
function (EloquentBuilder $q) use ($words) {
foreach ($words as $word) {
$q->orWhere('transaction_journals.description', 'LIKE', '%' . e($word) . '%');
@ -120,7 +119,7 @@ class Search implements SearchInterface
)->get(TransactionJournal::queryFields());
// encrypted
$all = Auth::user()->transactionJournals()->expanded()->where('transaction_journals.encrypted', 1)->get(TransactionJournal::queryFields());
$all = auth()->user()->transactionJournals()->expanded()->where('transaction_journals.encrypted', 1)->get(TransactionJournal::queryFields());
$set = $all->filter(
function (TransactionJournal $journal) use ($words) {
foreach ($words as $word) {

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Support;
use Auth;
use Carbon\Carbon;
use DB;
use FireflyIII\Models\Account;
@ -185,10 +184,10 @@ class Steam
{
$list = [];
$set = Auth::user()->transactions()
->whereIn('transactions.account_id', $accounts)
->groupBy(['transactions.account_id', 'transaction_journals.user_id'])
->get(['transactions.account_id', DB::raw('MAX(`transaction_journals`.`date`) as `max_date`')]);
$set = auth()->user()->transactions()
->whereIn('transactions.account_id', $accounts)
->groupBy(['transactions.account_id', 'transaction_journals.user_id'])
->get(['transactions.account_id', DB::raw('MAX(`transaction_journals`.`date`) as `max_date`')]);
foreach ($set as $entry) {
$list[intval($entry->account_id)] = new Carbon($entry->max_date);

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Support\Twig;
use Auth;
use FireflyIII\Models\LimitRepetition;
use FireflyIII\Support\CacheProperties;
use Twig_Extension;
@ -39,14 +38,14 @@ class Budget extends Twig_Extension
return $cache->get();
}
$sum
= Auth::user()->transactionJournals()
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budget_transaction_journal.budget_id')
->leftJoin('limit_repetitions', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
->before($repetition->enddate)
->after($repetition->startdate)
->where('limit_repetitions.id', '=', $repetition->id)
->get(['transaction_journals.*'])->sum('amount');
= auth()->user()->transactionJournals()
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budget_transaction_journal.budget_id')
->leftJoin('limit_repetitions', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
->before($repetition->enddate)
->after($repetition->startdate)
->where('limit_repetitions.id', '=', $repetition->id)
->get(['transaction_journals.*'])->sum('amount');
$cache->store($sum);
return $sum;

View File

@ -11,7 +11,6 @@ declare(strict_types = 1);
namespace FireflyIII\Validation;
use Auth;
use Config;
use Crypt;
use DB;
@ -85,7 +84,7 @@ class FireflyValidator extends Validator
if (intval($value) === 0) {
return true;
}
$count = DB::table($parameters[0])->where('user_id', Auth::user()->id)->where($field, $value)->count();
$count = DB::table($parameters[0])->where('user_id', auth()->user()->id)->where($field, $value)->count();
if ($count === 1) {
return true;
}
@ -256,7 +255,7 @@ class FireflyValidator extends Validator
$query = AccountMeta::
leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
->where('accounts.user_id', Auth::user()->id)
->where('accounts.user_id', auth()->user()->id)
->where('account_meta.name', 'accountNumber');
if (intval($accountId) > 0) {
@ -288,7 +287,7 @@ class FireflyValidator extends Validator
public function validateUniqueForUser($attribute, $value, $parameters): bool
{
$query = DB::table($parameters[0])->where($parameters[1], $value);
$query->where('user_id', Auth::user()->id);
$query->where('user_id', auth()->user()->id);
if (isset($parameters[2])) {
$query->where('id', '!=', $parameters[2]);
}
@ -324,7 +323,7 @@ class FireflyValidator extends Validator
$exclude = $parameters[2] ?? 0;
// get entries from table
$set = DB::table($table)->where('user_id', Auth::user()->id)
$set = DB::table($table)->where('user_id', auth()->user()->id)
->where('id', '!=', $exclude)->get([$field]);
foreach ($set as $entry) {
@ -349,7 +348,7 @@ class FireflyValidator extends Validator
{
$exclude = $parameters[0] ?? null;
$query = DB::table('piggy_banks')->whereNull('piggy_banks.deleted_at')
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', Auth::user()->id);
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', auth()->user()->id);
if (!is_null($exclude)) {
$query->where('piggy_banks.id', '!=', $exclude);
}
@ -444,7 +443,7 @@ class FireflyValidator extends Validator
$ignore = $existingAccount->id;
$value = $this->tryDecrypt($value);
$set = Auth::user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
$set = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
/** @var Account $entry */
foreach ($set as $entry) {
if ($entry->name == $value) {
@ -468,7 +467,7 @@ class FireflyValidator extends Validator
$ignore = $parameters[0] ?? 0;
$value = $this->tryDecrypt($value);
$set = Auth::user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
$set = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
/** @var Account $entry */
foreach ($set as $entry) {
if ($entry->name == $value) {
@ -492,7 +491,7 @@ class FireflyValidator extends Validator
$type = AccountType::whereType($search)->first();
$ignore = $parameters[0] ?? 0;
$set = Auth::user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
$set = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
/** @var Account $entry */
foreach ($set as $entry) {
if ($entry->name == $value) {