Various code optimalisations.

This commit is contained in:
James Cole 2018-07-08 07:59:58 +02:00
parent 10492e3b2f
commit 2f2f907ffe
59 changed files with 309 additions and 279 deletions

View File

@ -28,6 +28,7 @@ use Carbon\Carbon;
use FireflyConfig; use FireflyConfig;
use FireflyIII\Events\RequestedVersionCheckStatus; use FireflyIII\Events\RequestedVersionCheckStatus;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Update\UpdateTrait;
use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Services\Github\Object\Release; use FireflyIII\Services\Github\Object\Release;
use FireflyIII\Services\Github\Request\UpdateRequest; use FireflyIII\Services\Github\Request\UpdateRequest;
@ -39,6 +40,7 @@ use Log;
*/ */
class VersionCheckEventHandler class VersionCheckEventHandler
{ {
use UpdateTrait;
/** /**
* Checks with GitHub to see if there is a new version. * Checks with GitHub to see if there is a new version.
@ -72,7 +74,7 @@ class VersionCheckEventHandler
if ($diff < 604800) { if ($diff < 604800) {
Log::debug(sprintf('Checked for updates less than a week ago (on %s).', date('Y-m-d H:i:s', $lastCheckTime->data))); Log::debug(sprintf('Checked for updates less than a week ago (on %s).', date('Y-m-d H:i:s', $lastCheckTime->data)));
return; //return;
} }
// last check time was more than a week ago. // last check time was more than a week ago.
@ -81,86 +83,17 @@ class VersionCheckEventHandler
// have actual permission? // have actual permission?
if ($permission->data === -1) { if ($permission->data === -1) {
// never asked before. // never asked before.
session()->flash('info', (string)trans('firefly.check_for_updates_permission', ['link' => route('admin.update-check')])); //session()->flash('info', (string)trans('firefly.check_for_updates_permission', ['link' => route('admin.update-check')]));
//return;
return;
} }
$current = config('firefly.version');
$latestRelease = $this->getLatestRelease(); $latestRelease = $this->getLatestRelease();
$versionCheck = $this->versionCheck($latestRelease); $versionCheck = $this->versionCheck($latestRelease);
$string = ''; $resultString = $this->parseResult($latestRelease, $versionCheck);
if ($versionCheck === -2) { if (0 !== $versionCheck && '' !== $resultString) {
$string = (string)trans('firefly.update_check_error');
}
if ($versionCheck === -1 && null !== $latestRelease) {
// there is a new FF version!
// has it been released for at least three days?
$today = new Carbon;
if ($today->diffInDays($latestRelease->getUpdated(), true) > 3) {
$monthAndDayFormat = (string)trans('config.month_and_day');
$string = (string)trans(
'firefly.update_new_version_alert',
[
'your_version' => $current,
'new_version' => $latestRelease->getTitle(),
'date' => $latestRelease->getUpdated()->formatLocalized($monthAndDayFormat),
]
);
}
}
if (0 !== $versionCheck && '' !== $string) {
// flash info // flash info
session()->flash('info', $string); session()->flash('info', $resultString);
} }
FireflyConfig::set('last_update_check', time()); FireflyConfig::set('last_update_check', time());
} }
/**
* Get object for the latest release from GitHub.
*
* @return Release|null
*/
private function getLatestRelease(): ?Release
{
$return = null;
/** @var UpdateRequest $request */
$request = app(UpdateRequest::class);
try {
$request->call();
} catch (FireflyException $e) {
Log::error(sprintf('Could not check for updates: %s', $e->getMessage()));
}
// get releases from array.
$releases = $request->getReleases();
if (\count($releases) > 0) {
// first entry should be the latest entry:
/** @var Release $first */
$first = reset($releases);
$return = $first;
}
return $return;
}
/**
* Compare version and store result.
*
* @param Release|null $release
*
* @return int
*/
private function versionCheck(Release $release = null): int
{
if (null === $release) {
return -2;
}
$current = (string)config('firefly.version');
$check = version_compare($current, $release->getTitle());
Log::debug(sprintf('Comparing %s with %s, result is %s', $current, $release->getTitle(), $check));
return $check;
}
} }

View File

@ -43,6 +43,7 @@ class TransactionViewFilter implements FilterInterface
* *
* @param Collection $set * @param Collection $set
* @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.CyclomaticComplexity)
*
* @return Collection * @return Collection
*/ */
public function filter(Collection $set): Collection public function filter(Collection $set): Collection

View File

@ -147,6 +147,7 @@ class BudgetReportHelper implements BudgetReportHelperInterface
/** /**
* Calculate the expenses for a budget. * Calculate the expenses for a budget.
*
* @param Budget $budget * @param Budget $budget
* @param BudgetLimit $budgetLimit * @param BudgetLimit $budgetLimit
* @param Collection $accounts * @param Collection $accounts

View File

@ -55,6 +55,7 @@ interface PopupReportInterface
/** /**
* Group by budget. * Group by budget.
*
* @param Budget $budget * @param Budget $budget
* @param array $attributes * @param array $attributes
* *

View File

@ -0,0 +1,131 @@
<?php
/**
* UpdateTrait.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Helpers\Update;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Services\Github\Object\Release;
use FireflyIII\Services\Github\Request\UpdateRequest;
use Log;
/**
* Trait UpdateTrait
*
* @package FireflyIII\Helpers\Update
*/
trait UpdateTrait
{
/**
* Get object for the latest release from GitHub.
*
* @return Release|null
*/
public function getLatestRelease(): ?Release
{
$return = null;
/** @var UpdateRequest $request */
$request = app(UpdateRequest::class);
try {
$request->call();
} catch (FireflyException $e) {
Log::error(sprintf('Could not check for updates: %s', $e->getMessage()));
}
// get releases from array.
$releases = $request->getReleases();
if (\count($releases) > 0) {
// first entry should be the latest entry:
/** @var Release $first */
$first = reset($releases);
$return = $first;
}
return $return;
}
/**
* Parses the version check result in a human readable sentence.
*
* @param Release|null $release
* @param int $versionCheck
*
* @return string
*/
public function parseResult(Release $release = null, int $versionCheck): string
{
$current = (string)config('firefly.version');
$return = '';
if ($versionCheck === -2) {
$return = (string)trans('firefly.update_check_error');
}
if ($versionCheck === -1 && null !== $release) {
// there is a new FF version!
// has it been released for at least three days?
$today = new Carbon;
$releaseDate = $release->getUpdated();
if ($today->diffInDays($releaseDate, true) > 3) {
$monthAndDayFormat = (string)trans('config.month_and_day');
$return = (string)trans(
'firefly.update_new_version_alert',
[
'your_version' => $current,
'new_version' => $release->getTitle(),
'date' => $release->getUpdated()->formatLocalized($monthAndDayFormat),
]
);
}
}
if (0 === $versionCheck) {
// you are running the current version!
$return = (string)trans('firefly.update_current_version_alert', ['version' => $current]);
}
if (1 === $versionCheck && null !== $release) {
// you are running a newer version!
$return = (string)trans('firefly.update_newer_version_alert', ['your_version' => $current, 'new_version' => $release->getTitle()]);
}
return $return;
}
/**
* Compare version and store result.
*
* @param Release|null $release
*
* @return int
*/
public function versionCheck(Release $release = null): int
{
if (null === $release) {
return -2;
}
$current = (string)config('firefly.version');
$latest = $release->getTitle();
$check = version_compare($current, $latest);
Log::debug(sprintf('Comparing %s with %s, result is %s', $current, $latest, $check));
return $check;
}
}

View File

@ -254,6 +254,7 @@ class ReconcileController extends Controller
* @param Carbon $end * @param Carbon $end
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws FireflyException
*/ */
public function submit(ReconciliationStoreRequest $request, JournalRepositoryInterface $repository, Account $account, Carbon $start, Carbon $end) public function submit(ReconciliationStoreRequest $request, JournalRepositoryInterface $repository, Account $account, Carbon $start, Carbon $end)
{ {
@ -275,7 +276,7 @@ class ReconcileController extends Controller
$difference = $data['difference']; $difference = $data['difference'];
$source = $reconciliation; $source = $reconciliation;
$destination = $account; $destination = $account;
if (bccomp($difference, '0') === 1) { if (1 === bccomp($difference, '0')) {
// amount is positive. Add it to reconciliation? // amount is positive. Add it to reconciliation?
$source = $account; $source = $account;
$destination = $reconciliation; $destination = $reconciliation;
@ -401,7 +402,7 @@ class ReconcileController extends Controller
// amount pos neg influences the accounts: // amount pos neg influences the accounts:
$source = $this->repository->getJournalSourceAccounts($journal)->first(); $source = $this->repository->getJournalSourceAccounts($journal)->first();
$destination = $this->repository->getJournalDestinationAccounts($journal)->first(); $destination = $this->repository->getJournalDestinationAccounts($journal)->first();
if (bccomp($submitted['amount'], '0') === 1) { if (1 === bccomp($submitted['amount'], '0')) {
// amount is positive, switch accounts: // amount is positive, switch accounts:
[$source, $destination] = [$destination, $source]; [$source, $destination] = [$destination, $source];

View File

@ -18,6 +18,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @noinspection PhpUndefinedClassInspection */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Admin; namespace FireflyIII\Http\Controllers\Admin;

View File

@ -18,27 +18,24 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @noinspection PhpMethodParametersCountMismatchInspection */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Admin; namespace FireflyIII\Http\Controllers\Admin;
use Carbon\Carbon;
use FireflyConfig; use FireflyConfig;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Update\UpdateTrait;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser; use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Http\Middleware\IsSandStormUser; use FireflyIII\Http\Middleware\IsSandStormUser;
use FireflyIII\Services\Github\Object\Release;
use FireflyIII\Services\Github\Request\UpdateRequest;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Log;
/** /**
* Class HomeController. * Class HomeController.
*/ */
class UpdateController extends Controller class UpdateController extends Controller
{ {
use UpdateTrait;
/** /**
* ConfigurationController constructor. * ConfigurationController constructor.
@ -70,9 +67,9 @@ class UpdateController extends Controller
$permission = app('fireflyconfig')->get('permission_update_check', -1); $permission = app('fireflyconfig')->get('permission_update_check', -1);
$selected = $permission->data; $selected = $permission->data;
$options = [ $options = [
'-1' => trans('firefly.updates_ask_me_later'), -1 => trans('firefly.updates_ask_me_later'),
'0' => trans('firefly.updates_do_not_check'), 0 => trans('firefly.updates_do_not_check'),
'1' => trans('firefly.updates_enable_check'), 1 => trans('firefly.updates_enable_check'),
]; ];
return view('admin.update.index', compact('subTitle', 'subTitleIcon', 'selected', 'options')); return view('admin.update.index', compact('subTitle', 'subTitleIcon', 'selected', 'options'));
@ -98,55 +95,16 @@ class UpdateController extends Controller
*/ */
public function updateCheck() public function updateCheck()
{ {
$current = config('firefly.version'); $latestRelease = $this->getLatestRelease();
/** @var UpdateRequest $request */ $versionCheck = $this->versionCheck($latestRelease);
$request = app(UpdateRequest::class); $resultString = $this->parseResult($latestRelease, $versionCheck);
$check = -2;
$first = new Release(['id' => '0', 'title' => '0', 'updated' => '2017-01-01', 'content' => '']); if (0 !== $versionCheck && '' !== $resultString) {
$string = ''; // flash info
try { session()->flash('info', $resultString);
$request->call(); }
$releases = $request->getReleases();
// first entry should be the latest entry:
/** @var Release $first */
$first = reset($releases);
$check = version_compare($current, $first->getTitle());
FireflyConfig::set('last_update_check', time()); FireflyConfig::set('last_update_check', time());
} catch (FireflyException $e) {
Log::error(sprintf('Could not check for updates: %s', $e->getMessage()));
}
if ($check === -2) {
$string = (string)trans('firefly.update_check_error');
}
if ($check === -1) { return response()->json(['result' => $resultString]);
// there is a new FF version!
// has it been released for more than three days?
$today = new Carbon;
if ($today->diffInDays($first->getUpdated(), true) > 3) {
$string = (string)trans(
'firefly.update_new_version_alert',
[
'your_version' => $current,
'new_version' => $first->getTitle(),
'date' => $first->getUpdated()->formatLocalized($this->monthAndDayFormat),
]
);
}
if ($today->diffInDays($first->getUpdated(), true) <= 3) {
// tell user their running the current version.
$string = (string)trans('firefly.update_current_version_alert', ['version' => $current]);
}
}
if ($check === 0) {
// you are running the current version!
$string = (string)trans('firefly.update_current_version_alert', ['version' => $current]);
}
if ($check === 1) {
// you are running a newer version!
$string = (string)trans('firefly.update_newer_version_alert', ['your_version' => $current, 'new_version' => $first->getTitle()]);
}
return response()->json(['result' => $string]);
} }
} }

View File

@ -120,13 +120,13 @@ class UserController extends Controller
// add meta stuff. // add meta stuff.
$users->each( $users->each(
function (User $user) { function (User $user) use ($repository) {
$list = ['twoFactorAuthEnabled', 'twoFactorAuthSecret']; $list = ['twoFactorAuthEnabled', 'twoFactorAuthSecret'];
$preferences = Preferences::getArrayForUser($user, $list); $preferences = Preferences::getArrayForUser($user, $list);
$user->isAdmin = $user->hasRole('owner'); $user->isAdmin = $repository->hasRole($user, 'owner');
$is2faEnabled = 1 === $preferences['twoFactorAuthEnabled']; $is2faEnabled = 1 === $preferences['twoFactorAuthEnabled'];
$has2faSecret = null !== $preferences['twoFactorAuthSecret']; $has2faSecret = null !== $preferences['twoFactorAuthSecret'];
$user->has2FA = ($is2faEnabled && $has2faSecret) ? true : false; $user->has2FA = ($is2faEnabled && $has2faSecret);
$user->prefs = $preferences; $user->prefs = $preferences;
} }
); );

View File

@ -18,6 +18,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Auth; namespace FireflyIII\Http\Controllers\Auth;

View File

@ -18,6 +18,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Auth; namespace FireflyIII\Http\Controllers\Auth;
@ -123,7 +124,7 @@ class LoginController extends Controller
public function showLoginForm(Request $request) public function showLoginForm(Request $request)
{ {
$count = DB::table('users')->count(); $count = DB::table('users')->count();
if ($count === 0) { if (0 === $count) {
return redirect(route('register')); // @codeCoverageIgnore return redirect(route('register')); // @codeCoverageIgnore
} }

View File

@ -18,6 +18,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Auth; namespace FireflyIII\Http\Controllers\Auth;

View File

@ -18,6 +18,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Auth; namespace FireflyIII\Http\Controllers\Auth;

View File

@ -59,7 +59,7 @@ class TwoFactorController extends Controller
return redirect(route('index')); return redirect(route('index'));
} }
if (0 === \strlen((string)$secret)) { if ('' === (string)$secret) {
throw new FireflyException('Your two factor authentication secret is empty, which it cannot be at this point. Please check the log files.'); throw new FireflyException('Your two factor authentication secret is empty, which it cannot be at this point. Please check the log files.');
} }
$request->session()->flash('two-factor-secret', $secret); $request->session()->flash('two-factor-secret', $secret);

View File

@ -326,7 +326,7 @@ class BillController extends Controller
// find first rule group, or create one: // find first rule group, or create one:
$count = $this->ruleGroupRepos->count(); $count = $this->ruleGroupRepos->count();
if ($count === 0) { if (0 === $count) {
$data = [ $data = [
'title' => (string)trans('firefly.rulegroup_for_bills_title'), 'title' => (string)trans('firefly.rulegroup_for_bills_title'),
'description' => (string)trans('firefly.rulegroup_for_bills_description'), 'description' => (string)trans('firefly.rulegroup_for_bills_description'),

View File

@ -105,8 +105,8 @@ class BudgetController extends Controller
$days = $start->diffInDays($end); $days = $start->diffInDays($end);
$daysInMonth = $start->diffInDays($end); $daysInMonth = $start->diffInDays($end);
} }
$days = $days === 0 ? 1 : $days; $days = 0 === $days ? 1 : $days;
$daysInMonth = $daysInMonth === 0 ? 1 : $daysInMonth; $daysInMonth = 0 === $daysInMonth ? 1 : $daysInMonth;
// calculate left in budget: // calculate left in budget:
$spent = $repository->spentInPeriod(new Collection([$budget]), new Collection, $start, $end); $spent = $repository->spentInPeriod(new Collection([$budget]), new Collection, $start, $end);
@ -258,7 +258,7 @@ class BudgetController extends Controller
$end = app('navigation')->endOfPeriod($start, $range); $end = app('navigation')->endOfPeriod($start, $range);
} catch (Exception $e) { } catch (Exception $e) {
// start and end are already defined. // start and end are already defined.
Log::debug('start and end are already defined.'); Log::debug(sprintf('start and end are already defined: %s', $e->getMessage()));
} }
} }
@ -273,8 +273,8 @@ class BudgetController extends Controller
$days = $start->diffInDays($end); $days = $start->diffInDays($end);
$daysInMonth = $start->diffInDays($end); $daysInMonth = $start->diffInDays($end);
} }
$days = $days === 0 ? 1 : $days; $days = 0 === $days ? 1 : $days;
$daysInMonth = $daysInMonth === 0 ? 1 : $daysInMonth; $daysInMonth = 0 === $daysInMonth ? 1 : $daysInMonth;
$next = clone $end; $next = clone $end;
@ -489,7 +489,7 @@ class BudgetController extends Controller
$end = Carbon::createFromFormat('Y-m-d', $request->string('end')); $end = Carbon::createFromFormat('Y-m-d', $request->string('end'));
$defaultCurrency = app('amount')->getDefaultCurrency(); $defaultCurrency = app('amount')->getDefaultCurrency();
$amount = $request->get('amount'); $amount = $request->get('amount');
$page = $request->integer('page') === 0 ? 1 : $request->integer('page'); $page = 0 === $request->integer('page') ? 1 : $request->integer('page');
$this->repository->cleanupBudgets(); $this->repository->cleanupBudgets();
$this->repository->setAvailableBudget($defaultCurrency, $start, $end, $amount); $this->repository->setAvailableBudget($defaultCurrency, $start, $end, $amount);
Preferences::mark(); Preferences::mark();

View File

@ -268,7 +268,7 @@ class CategoryController extends Controller
} }
// prep for current period // prep for current period
if (0 === \strlen($moment)) { if ('' === $moment) {
/** @var Carbon $start */ /** @var Carbon $start */
$start = clone session('start', app('navigation')->startOfPeriod(new Carbon, $range)); $start = clone session('start', app('navigation')->startOfPeriod(new Carbon, $range));
/** @var Carbon $end */ /** @var Carbon $end */

View File

@ -107,7 +107,7 @@ class BudgetController extends Controller
while ($end >= $current) { while ($end >= $current) {
$currentEnd = app('navigation')->endOfPeriod($current, $step); $currentEnd = app('navigation')->endOfPeriod($current, $step);
if ($step === '1Y') { if ('1Y' === $step) {
$currentEnd->subDay(); // @codeCoverageIgnore $currentEnd->subDay(); // @codeCoverageIgnore
} }
$spent = $this->repository->spentInPeriod($budgetCollection, new Collection, $current, $currentEnd); $spent = $this->repository->spentInPeriod($budgetCollection, new Collection, $current, $currentEnd);
@ -544,7 +544,7 @@ class BudgetController extends Controller
$return[$name] = $row; $return[$name] = $row;
} }
} }
unset($rows, $row); unset($rows);
return $return; return $return;
} }

View File

@ -105,13 +105,13 @@ class PiggyBankController extends Controller
$chartData[$label] = $currentSum; $chartData[$label] = $currentSum;
$oldest = app('navigation')->addPeriod($oldest, $step, 0); $oldest = app('navigation')->addPeriod($oldest, $step, 0);
} }
/** @var Collection $filtered */ /** @var Collection $finalFiltered */
$finalFiltered = $set->filter( $finalFiltered = $set->filter(
function (PiggyBankEvent $event) use ($today) { function (PiggyBankEvent $event) use ($today) {
return $event->date->lte($today); return $event->date->lte($today);
} }
); );
$finalSum = $filtered->sum('amount'); $finalSum = $finalFiltered->sum('amount');
$finalLabel = $today->formatLocalized((string)trans('config.month_and_day')); $finalLabel = $today->formatLocalized((string)trans('config.month_and_day'));
$chartData[$finalLabel] = $finalSum; $chartData[$finalLabel] = $finalSum;

View File

@ -157,7 +157,7 @@ class Controller extends BaseController
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($transactions as $transaction) { foreach ($transactions as $transaction) {
$account = $transaction->account; $account = $transaction->account;
if (\in_array($account->accountType->type, $valid)) { if (in_array($account->accountType->type, $valid, true)) {
return redirect(route('accounts.show', [$account->id])); return redirect(route('accounts.show', [$account->id]));
} }
} }

View File

@ -87,7 +87,7 @@ class DebugController extends Controller
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
} catch (Exception $e) { } catch (Exception $e) {
// don't care // don't care
Log::debug('Called twig:clean.'); Log::debug(sprintf('Called twig:clean: %s', $e->getMessage()));
} }
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
Log::debug('Call view:clear...'); Log::debug('Call view:clear...');
@ -202,7 +202,7 @@ class DebugController extends Controller
break; break;
} }
} }
if ($found === false) { if (false === $found) {
$return .= 'touch ' . $route->getName() . '.md;'; $return .= 'touch ' . $route->getName() . '.md;';
} }
} }
@ -258,7 +258,7 @@ class DebugController extends Controller
{ {
$packages = []; $packages = [];
$file = \dirname(__DIR__, 3) . '/vendor/composer/installed.json'; $file = \dirname(__DIR__, 3) . '/vendor/composer/installed.json';
if (!($file === false) && file_exists($file)) { if (!(false === $file) && file_exists($file)) {
// file exists! // file exists!
$content = file_get_contents($file); $content = file_get_contents($file);
$json = json_decode($content, true); $json = json_decode($content, true);

View File

@ -90,10 +90,10 @@ class HelpController extends Controller
} }
// get help content from Github: // get help content from Github:
$content = $this->help->getFromGithub($route, $language); $content = $this->help->getFromGitHub($route, $language);
// content will have 0 length when Github failed. Try en_US when it does: // content will have 0 length when Github failed. Try en_US when it does:
if (0 === \strlen($content)) { if ('' === $content) {
$language = 'en_US'; $language = 'en_US';
// also check cache first: // also check cache first:
@ -104,11 +104,11 @@ class HelpController extends Controller
return $content; return $content;
} }
$content = $this->help->getFromGithub($route, $language); $content = $this->help->getFromGitHub($route, $language);
} }
// help still empty? // help still empty?
if (0 !== \strlen($content)) { if ('' !== $content) {
$this->help->putInCache($route, $language, $content); $this->help->putInCache($route, $language, $content);
return $content; return $content;

View File

@ -89,10 +89,10 @@ class IndexController extends Controller
$hasPreReq = (bool)config(sprintf('import.has_prereq.%s', $importProvider)); $hasPreReq = (bool)config(sprintf('import.has_prereq.%s', $importProvider));
$hasConfig = (bool)config(sprintf('import.has_job_config.%s', $importProvider)); $hasConfig = (bool)config(sprintf('import.has_job_config.%s', $importProvider));
// if job provider has no prerequisites: // if job provider has no prerequisites:
if ($hasPreReq === false) { if (false === $hasPreReq) {
Log::debug('Provider has no prerequisites. Continue.'); Log::debug('Provider has no prerequisites. Continue.');
// if job provider also has no configuration: // if job provider also has no configuration:
if ($hasConfig === false) { if (false === $hasConfig) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
Log::debug('Provider needs no configuration for job. Job is ready to start.'); Log::debug('Provider needs no configuration for job. Job is ready to start.');
$this->repository->updateStatus($importJob, 'ready_to_run'); $this->repository->updateStatus($importJob, 'ready_to_run');
@ -130,7 +130,7 @@ class IndexController extends Controller
// update job to say "has_prereq". // update job to say "has_prereq".
$this->repository->setStatus($importJob, 'has_prereq'); $this->repository->setStatus($importJob, 'has_prereq');
if ($hasConfig === false) { if (false === $hasConfig) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
Log::debug('Provider has no configuration. Job is ready to start.'); Log::debug('Provider has no configuration. Job is ready to start.');
$this->repository->updateStatus($importJob, 'ready_to_run'); $this->repository->updateStatus($importJob, 'ready_to_run');
@ -208,16 +208,16 @@ class IndexController extends Controller
$enabled = (bool)config(sprintf('import.enabled.%s', $providerName)); $enabled = (bool)config(sprintf('import.enabled.%s', $providerName));
$allowedForDemo = (bool)config(sprintf('import.allowed_for_demo.%s', $providerName)); $allowedForDemo = (bool)config(sprintf('import.allowed_for_demo.%s', $providerName));
$allowedForUser = (bool)config(sprintf('import.allowed_for_user.%s', $providerName)); $allowedForUser = (bool)config(sprintf('import.allowed_for_user.%s', $providerName));
if ($enabled === false) { if (false === $enabled) {
//Log::debug('Provider is not enabled. NEXT!'); //Log::debug('Provider is not enabled. NEXT!');
continue; continue;
} }
if ($isDemoUser === true && $allowedForDemo === false) { if (true === $isDemoUser && false === $allowedForDemo) {
//Log::debug('User is demo and this provider is not allowed for demo user. NEXT!'); //Log::debug('User is demo and this provider is not allowed for demo user. NEXT!');
continue; continue;
} }
if ($isDemoUser === false && $allowedForUser === false && $isDebug === false) { if (false === $isDemoUser && false === $allowedForUser && false === $isDebug) {
//Log::debug('User is not demo and this provider is not allowed for such users. NEXT!'); //Log::debug('User is not demo and this provider is not allowed for such users. NEXT!');
continue; // @codeCoverageIgnore continue; // @codeCoverageIgnore
} }
@ -227,7 +227,7 @@ class IndexController extends Controller
]; ];
$class = (string)config(sprintf('import.prerequisites.%s', $providerName)); $class = (string)config(sprintf('import.prerequisites.%s', $providerName));
$result = false; $result = false;
if ($class !== '' && class_exists($class)) { if ('' !== $class && class_exists($class)) {
//Log::debug('Will not check prerequisites.'); //Log::debug('Will not check prerequisites.');
/** @var PrerequisitesInterface $object */ /** @var PrerequisitesInterface $object */
$object = app($class); $object = app($class);

View File

@ -90,7 +90,7 @@ class JobStatusController extends Controller
'download_config_text' => '', 'download_config_text' => '',
]; ];
if ($importJob->provider === 'file') { if ('file' === $importJob->provider) {
$json['download_config'] = true; $json['download_config'] = true;
$json['download_config_text'] $json['download_config_text']
= trans('import.should_download_config', ['route' => route('import.job.download', [$importJob->key])]) . ' ' = trans('import.should_download_config', ['route' => route('import.job.download', [$importJob->key])]) . ' '
@ -101,10 +101,10 @@ class JobStatusController extends Controller
if (null !== $importJob->tag_id) { if (null !== $importJob->tag_id) {
$count = $importJob->tag->transactionJournals->count(); $count = $importJob->tag->transactionJournals->count();
} }
if ($count === 0) { if (0 === $count) {
$json['report_txt'] = trans('import.result_no_transactions'); $json['report_txt'] = trans('import.result_no_transactions');
} }
if ($count === 1 && null !== $importJob->tag_id) { if (1 === $count && null !== $importJob->tag_id) {
$json['report_txt'] = trans( $json['report_txt'] = trans(
'import.result_one_transaction', ['route' => route('tags.show', [$importJob->tag_id, 'all']), 'tag' => $importJob->tag->tag] 'import.result_one_transaction', ['route' => route('tags.show', [$importJob->tag_id, 'all']), 'tag' => $importJob->tag->tag]
); );

View File

@ -73,7 +73,7 @@ class PrerequisitesController extends Controller
{ {
// catch impossible status: // catch impossible status:
$allowed = ['new']; $allowed = ['new'];
if (null !== $importJob && !in_array($importJob->status, $allowed)) { if (null !== $importJob && !in_array($importJob->status, $allowed, true)) {
Log::error(sprintf('Job has state "%s" but this Prerequisites::index() only accepts %s', $importJob->status, json_encode($allowed))); Log::error(sprintf('Job has state "%s" but this Prerequisites::index() only accepts %s', $importJob->status, json_encode($allowed)));
session()->flash('error', trans('import.bad_job_status', ['status' => $importJob->status])); session()->flash('error', trans('import.bad_job_status', ['status' => $importJob->status]));

View File

@ -146,7 +146,7 @@ class AutoCompleteController extends Controller
$set = $repository->getAccountsByType([AccountType::EXPENSE, AccountType::BENEFICIARY]); $set = $repository->getAccountsByType([AccountType::EXPENSE, AccountType::BENEFICIARY]);
$filtered = $set->filter( $filtered = $set->filter(
function (Account $account) { function (Account $account) {
if ($account->active === true) { if (true === $account->active) {
return $account; return $account;
} }
@ -203,7 +203,7 @@ class AutoCompleteController extends Controller
$set = $repository->getAccountsByType([AccountType::REVENUE]); $set = $repository->getAccountsByType([AccountType::REVENUE]);
$filtered = $set->filter( $filtered = $set->filter(
function (Account $account) { function (Account $account) {
if ($account->active === true) { if (true === $account->active) {
return $account; return $account;
} }

View File

@ -153,7 +153,7 @@ class BoxController extends Controller
$incomes[$currencyId] = Amount::formatAnything($currency, $incomes[$currencyId] ?? '0', false); $incomes[$currencyId] = Amount::formatAnything($currency, $incomes[$currencyId] ?? '0', false);
$expenses[$currencyId] = Amount::formatAnything($currency, $expenses[$currencyId] ?? '0', false); $expenses[$currencyId] = Amount::formatAnything($currency, $expenses[$currencyId] ?? '0', false);
} }
if (\count($sums) === 0) { if (0 === \count($sums)) {
$currency = app('amount')->getDefaultCurrency(); $currency = app('amount')->getDefaultCurrency();
$sums[$currency->id] = Amount::formatAnything($currency, '0', false); $sums[$currency->id] = Amount::formatAnything($currency, '0', false);
$incomes[$currency->id] = Amount::formatAnything($currency, '0', false); $incomes[$currency->id] = Amount::formatAnything($currency, '0', false);
@ -248,7 +248,7 @@ class BoxController extends Controller
$accountCurrency = null; $accountCurrency = null;
$balance = $balances[$account->id] ?? '0'; $balance = $balances[$account->id] ?? '0';
$currencyId = (int)$repository->getMetaValue($account, 'currency_id'); $currencyId = (int)$repository->getMetaValue($account, 'currency_id');
if ($currencyId !== 0) { if (0 !== $currencyId) {
$accountCurrency = $currencyRepos->findNull($currencyId); $accountCurrency = $currencyRepos->findNull($currencyId);
} }
if (null === $accountCurrency) { if (null === $accountCurrency) {
@ -259,7 +259,7 @@ class BoxController extends Controller
// to better reflect that this is not money that is actually "yours". // to better reflect that this is not money that is actually "yours".
$role = (string)$repository->getMetaValue($account, 'accountRole'); $role = (string)$repository->getMetaValue($account, 'accountRole');
$virtualBalance = (string)$account->virtual_balance; $virtualBalance = (string)$account->virtual_balance;
if ($role === 'ccAsset' && $virtualBalance !== '' && (float)$virtualBalance > 0) { if ('ccAsset' === $role && '' !== $virtualBalance && (float)$virtualBalance > 0) {
$balance = bcsub($balance, $virtualBalance); $balance = bcsub($balance, $virtualBalance);
} }

View File

@ -81,6 +81,7 @@ class ReportController extends Controller
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
* *
* @throws FireflyException * @throws FireflyException
* @throws \Throwable
*/ */
public function general(Request $request) public function general(Request $request)
{ {
@ -229,13 +230,13 @@ class ReportController extends Controller
try { try {
$attributes['startDate'] = Carbon::createFromFormat('Ymd', $attributes['startDate']); $attributes['startDate'] = Carbon::createFromFormat('Ymd', $attributes['startDate']);
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
throw new FireflyException('Could not parse start date "' . e($attributes['startDate']) . '".'); throw new FireflyException(sprintf('Could not parse start date "%s": %s', $attributes['startDate'], $e->getMessage()));
} }
try { try {
$attributes['endDate'] = Carbon::createFromFormat('Ymd', $attributes['endDate']); $attributes['endDate'] = Carbon::createFromFormat('Ymd', $attributes['endDate']);
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
throw new FireflyException('Could not parse start date "' . e($attributes['endDate']) . '".'); throw new FireflyException(sprintf('Could not parse end date "%s": %s', $attributes['endDate'], $e->getMessage()));
} }
return $attributes; return $attributes;

View File

@ -24,7 +24,6 @@ namespace FireflyIII\Http\Controllers;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Preferences; use Preferences;
use View; use View;
@ -86,11 +85,10 @@ class PreferencesController extends Controller
/** /**
* @param Request $request * @param Request $request
* @param UserRepositoryInterface $repository
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/ */
public function postIndex(Request $request, UserRepositoryInterface $repository) public function postIndex(Request $request)
{ {
// front page accounts // front page accounts
$frontPageAccounts = []; $frontPageAccounts = [];

View File

@ -210,14 +210,14 @@ class ProfileController extends Controller
$this->createOAuthKeys(); $this->createOAuthKeys();
if ($count === 0) { if (0 === $count) {
/** @var ClientRepository $repository */ /** @var ClientRepository $repository */
$repository = app(ClientRepository::class); $repository = app(ClientRepository::class);
$repository->createPersonalAccessClient(null, config('app.name') . ' Personal Access Client', 'http://localhost'); $repository->createPersonalAccessClient(null, config('app.name') . ' Personal Access Client', 'http://localhost');
} }
$subTitle = auth()->user()->email; $subTitle = auth()->user()->email;
$userId = auth()->user()->id; $userId = auth()->user()->id;
$enabled2FA = (int)Preferences::get('twoFactorAuthEnabled', 0)->data === 1; $enabled2FA = 1 === (int)Preferences::get('twoFactorAuthEnabled', 0)->data;
// get access token or create one. // get access token or create one.
$accessToken = Preferences::get('access_token', null); $accessToken = Preferences::get('access_token', null);

View File

@ -18,7 +18,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @noinspection PhpMethodParametersCountMismatchInspection */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Recurring; namespace FireflyIII\Http\Controllers\Recurring;
@ -64,13 +64,14 @@ class IndexController extends Controller
); );
} }
/** /**
* @param Request $request * @param Request $request
* *
* @throws FireflyException * @throws FireflyException
* @return JsonResponse * @return JsonResponse
*/ */
function events(Request $request): JsonResponse public function events(Request $request): JsonResponse
{ {
$return = []; $return = [];
$start = Carbon::createFromFormat('Y-m-d', $request->get('start')); $start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
@ -202,7 +203,7 @@ class IndexController extends Controller
$subTitle = trans('firefly.overview_for_recurrence', ['title' => $recurrence->title]); $subTitle = trans('firefly.overview_for_recurrence', ['title' => $recurrence->title]);
return view('recurring.show', compact('recurrence', 'subTitle', 'array','transactions')); return view('recurring.show', compact('recurrence', 'subTitle', 'array', 'transactions'));
} }
/** /**
@ -216,7 +217,7 @@ class IndexController extends Controller
$date = Carbon::createFromFormat('Y-m-d', $request->get('date')); $date = Carbon::createFromFormat('Y-m-d', $request->get('date'));
$preSelected = (string)$request->get('pre_select'); $preSelected = (string)$request->get('pre_select');
$result = []; $result = [];
if ($date > $today || (string)$request->get('past') === 'true') { if ($date > $today || 'true' === (string)$request->get('past')) {
$weekly = sprintf('weekly,%s', $date->dayOfWeekIso); $weekly = sprintf('weekly,%s', $date->dayOfWeekIso);
$monthly = sprintf('monthly,%s', $date->day); $monthly = sprintf('monthly,%s', $date->day);
$dayOfWeek = trans(sprintf('config.dow_%s', $date->dayOfWeekIso)); $dayOfWeek = trans(sprintf('config.dow_%s', $date->dayOfWeekIso));

View File

@ -98,7 +98,6 @@ class ExpenseController extends Controller
} }
$together[$categoryId]['grand_total'] = bcadd($spentInfo['grand_total'], $together[$categoryId]['grand_total']); $together[$categoryId]['grand_total'] = bcadd($spentInfo['grand_total'], $together[$categoryId]['grand_total']);
} }
unset($spentInfo);
$result = view('reports.partials.exp-budgets', compact('together'))->render(); $result = view('reports.partials.exp-budgets', compact('together'))->render();
$cache->store($result); $cache->store($result);
@ -146,7 +145,6 @@ class ExpenseController extends Controller
} }
$together[$categoryId]['grand_total'] = bcadd($spentInfo['grand_total'], $together[$categoryId]['grand_total']); $together[$categoryId]['grand_total'] = bcadd($spentInfo['grand_total'], $together[$categoryId]['grand_total']);
} }
unset($spentInfo);
foreach ($earned as $categoryId => $earnedInfo) { foreach ($earned as $categoryId => $earnedInfo) {
if (!isset($together[$categoryId])) { if (!isset($together[$categoryId])) {
$together[$categoryId]['earned'] = $earnedInfo; $together[$categoryId]['earned'] = $earnedInfo;

View File

@ -276,7 +276,7 @@ class ReportController extends Controller
* *
* @return mixed * @return mixed
* *
* @throws \Throwable
*/ */
public function options(string $reportType) public function options(string $reportType)
{ {
@ -426,7 +426,7 @@ class ReportController extends Controller
$set = new Collection; $set = new Collection;
$names = $revenue->pluck('name')->toArray(); $names = $revenue->pluck('name')->toArray();
foreach ($expense as $exp) { foreach ($expense as $exp) {
if (\in_array($exp->name, $names)) { if (in_array($exp->name, $names, true)) {
$set->push($exp); $set->push($exp);
} }
} }

View File

@ -104,7 +104,7 @@ class RuleController extends Controller
$oldActions = []; $oldActions = [];
$returnToBill = false; $returnToBill = false;
if ($request->get('return') === 'true') { if ('true' === $request->get('return')) {
$returnToBill = true; $returnToBill = true;
} }
@ -359,7 +359,7 @@ class RuleController extends Controller
Preferences::mark(); Preferences::mark();
// redirect to show bill. // redirect to show bill.
if ($request->get('return_to_bill') === 'true' && (int)$request->get('bill_id') > 0) { if ('true' === $request->get('return_to_bill') && (int)$request->get('bill_id') > 0) {
return redirect(route('bills.show', [(int)$request->get('bill_id')])); // @codeCoverageIgnore return redirect(route('bills.show', [(int)$request->get('bill_id')])); // @codeCoverageIgnore
} }
@ -792,6 +792,7 @@ class RuleController extends Controller
private function getTriggersForBill(Bill $bill): array private function getTriggersForBill(Bill $bill): array
{ {
$triggers = []; $triggers = [];
/** @noinspection BadExceptionsProcessingInspection */
try { try {
$triggers[] = view( $triggers[] = view(
'rules.partials.trigger', 'rules.partials.trigger',
@ -822,6 +823,7 @@ class RuleController extends Controller
'count' => 3, 'count' => 3,
] ]
)->render(); )->render();
$triggers[] = view( $triggers[] = view(
'rules.partials.trigger', 'rules.partials.trigger',
[ [

View File

@ -18,6 +18,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @noinspection PhpMethodParametersCountMismatchInspection */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Http\Controllers; namespace FireflyIII\Http\Controllers;
@ -226,7 +227,7 @@ class TagController extends Controller
$sums = $repository->sumsOfTag($tag, $start, $end); $sums = $repository->sumsOfTag($tag, $start, $end);
return view('tags.show', compact('apiKey', 'tag', 'sums', 'periods', 'subTitle', 'subTitleIcon', 'transactions', 'start', 'end', 'moment')); return view('tags.show', compact('tag', 'sums', 'periods', 'subTitle', 'subTitleIcon', 'transactions', 'start', 'end', 'moment'));
} }
/** /**

View File

@ -95,9 +95,9 @@ class BulkController extends Controller
{ {
$journalIds = $request->get('journals'); $journalIds = $request->get('journals');
$journalIds = \is_array($journalIds) ? $journalIds : []; $journalIds = \is_array($journalIds) ? $journalIds : [];
$ignoreCategory = (int)$request->get('ignore_category') === 1; $ignoreCategory = 1 === (int)$request->get('ignore_category');
$ignoreBudget = (int)$request->get('ignore_budget') === 1; $ignoreBudget = 1 === (int)$request->get('ignore_budget');
$ignoreTags = (int)$request->get('ignore_tags') === 1; $ignoreTags = 1 === (int)$request->get('ignore_tags');
$count = 0; $count = 0;
foreach ($journalIds as $journalId) { foreach ($journalIds as $journalId) {
@ -110,20 +110,20 @@ class BulkController extends Controller
Log::debug(sprintf('Found journal #%d', $journal->id)); Log::debug(sprintf('Found journal #%d', $journal->id));
// update category if not told to ignore // update category if not told to ignore
if ($ignoreCategory === false) { if (false === $ignoreCategory) {
Log::debug(sprintf('Set category to %s', $request->string('category'))); Log::debug(sprintf('Set category to %s', $request->string('category')));
$this->repository->updateCategory($journal, $request->string('category')); $this->repository->updateCategory($journal, $request->string('category'));
} }
// update budget if not told to ignore (and is withdrawal) // update budget if not told to ignore (and is withdrawal)
if ($ignoreBudget === false) { if (false === $ignoreBudget) {
Log::debug(sprintf('Set budget to %d', $request->integer('budget_id'))); Log::debug(sprintf('Set budget to %d', $request->integer('budget_id')));
$this->repository->updateBudget($journal, $request->integer('budget_id')); $this->repository->updateBudget($journal, $request->integer('budget_id'));
} }
// update tags: // update tags:
if ($ignoreTags === false) { if (false === $ignoreTags) {
Log::debug(sprintf('Set tags to %s', $request->string('budget_id'))); Log::debug(sprintf('Set tags to %s', $request->string('budget_id')));
$this->repository->updateTags($journal, ['tags' => explode(',', $request->string('tags'))]); $this->repository->updateTags($journal, ['tags' => explode(',', $request->string('tags'))]);
} }

View File

@ -153,12 +153,12 @@ class MassController extends Controller
// transform to array // transform to array
$transactions = $collection->map( $transactions = $collection->map(
function (Transaction $transaction) use ($transformer) { function (Transaction $transaction) use ($transformer) {
$transaction = $transformer->transform($transaction); $transformed = $transformer->transform($transaction);
// make sure amount is positive: // make sure amount is positive:
$transaction['amount'] = app('steam')->positive((string)$transaction['amount']); $transformed['amount'] = app('steam')->positive((string)$transformed['amount']);
$transaction['foreign_amount'] = app('steam')->positive((string)$transaction['foreign_amount']); $transformed['foreign_amount'] = app('steam')->positive((string)$transformed['foreign_amount']);
return $transaction; return $transformed;
} }
); );
@ -177,7 +177,7 @@ class MassController extends Controller
$count = 0; $count = 0;
if (\is_array($journalIds)) { if (\is_array($journalIds)) {
foreach ($journalIds as $journalId) { foreach ($journalIds as $journalId) {
$journal = $repository->find((int)$journalId); $journal = $repository->findNull((int)$journalId);
if (null !== $journal) { if (null !== $journal) {
// get optional fields: // get optional fields:
$what = strtolower($this->repository->getTransactionType($journal)); $what = strtolower($this->repository->getTransactionType($journal));
@ -206,7 +206,7 @@ class MassController extends Controller
'category_id' => null, 'category_id' => null,
'category_name' => $category, 'category_name' => $category,
'budget_id' => (int)$budgetId, 'budget_id' => $budgetId,
'budget_name' => null, 'budget_name' => null,
'source_id' => (int)$sourceAccountId, 'source_id' => (int)$sourceAccountId,
'source_name' => $sourceAccountName, 'source_name' => $sourceAccountName,

View File

@ -113,13 +113,13 @@ class SingleController extends Controller
'budget_id' => $budgetId, 'budget_id' => $budgetId,
'category' => $categoryName, 'category' => $categoryName,
'tags' => $tags, 'tags' => $tags,
'interest_date' => $journal->getMeta('interest_date'), 'interest_date' => $this->repository->getMetaField($journal, 'interest_date'),
'book_date' => $journal->getMeta('book_date'), 'book_date' => $this->repository->getMetaField($journal, 'book_date'),
'process_date' => $journal->getMeta('process_date'), 'process_date' => $this->repository->getMetaField($journal, 'process_date'),
'due_date' => $journal->getMeta('due_date'), 'due_date' => $this->repository->getMetaField($journal, 'due_date'),
'payment_date' => $journal->getMeta('payment_date'), 'payment_date' => $this->repository->getMetaField($journal, 'payment_date'),
'invoice_date' => $journal->getMeta('invoice_date'), 'invoice_date' => $this->repository->getMetaField($journal, 'invoice_date'),
'internal_reference' => $journal->getMeta('internal_reference'), 'internal_reference' => $this->repository->getMetaField($journal, 'internal_reference'),
'notes' => '', 'notes' => '',
]; ];
@ -143,7 +143,7 @@ class SingleController extends Controller
public function create(Request $request, string $what = TransactionType::DEPOSIT) public function create(Request $request, string $what = TransactionType::DEPOSIT)
{ {
$what = strtolower($what); $what = strtolower($what);
$what = $request->old('what') ?? $what; $what = (string)($request->old('what') ?? $what);
$budgets = ExpandedForm::makeSelectListWithEmpty($this->budgets->getActiveBudgets()); $budgets = ExpandedForm::makeSelectListWithEmpty($this->budgets->getActiveBudgets());
$preFilled = session()->has('preFilled') ? session('preFilled') : []; $preFilled = session()->has('preFilled') ? session('preFilled') : [];
$subTitle = trans('form.add_new_' . $what); $subTitle = trans('form.add_new_' . $what);
@ -155,10 +155,10 @@ class SingleController extends Controller
$currencyID = (int)$request->old('amount_currency_id_amount'); $currencyID = (int)$request->old('amount_currency_id_amount');
$preFilled['amount_currency_id_amount'] = $currencyID; $preFilled['amount_currency_id_amount'] = $currencyID;
if (($what === 'withdrawal' || $what === 'transfer') && $source > 0) { if (('withdrawal' === $what || 'transfer' === $what) && $source > 0) {
$preFilled['source_id'] = $source; $preFilled['source_id'] = $source;
} }
if ($what === 'deposit' && $source > 0) { if ('deposit' === $what && $source > 0) {
$preFilled['destination_id'] = $source; $preFilled['destination_id'] = $source;
} }

View File

@ -32,7 +32,6 @@ use FireflyIII\Http\Requests\SplitJournalFormRequest;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
@ -49,9 +48,6 @@ use View;
*/ */
class SplitController extends Controller class SplitController extends Controller
{ {
/** @var AccountRepositoryInterface */
private $accounts;
/** @var AttachmentHelperInterface */ /** @var AttachmentHelperInterface */
private $attachments; private $attachments;
@ -73,7 +69,6 @@ class SplitController extends Controller
// some useful repositories: // some useful repositories:
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
$this->accounts = app(AccountRepositoryInterface::class);
$this->budgets = app(BudgetRepositoryInterface::class); $this->budgets = app(BudgetRepositoryInterface::class);
$this->attachments = app(AttachmentHelperInterface::class); $this->attachments = app(AttachmentHelperInterface::class);
$this->currencies = app(CurrencyRepositoryInterface::class); $this->currencies = app(CurrencyRepositoryInterface::class);

View File

@ -85,7 +85,6 @@ class TransactionController extends Controller
$types = config('firefly.transactionTypesByWhat.' . $what); $types = config('firefly.transactionTypesByWhat.' . $what);
$page = (int)$request->get('page'); $page = (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data; $pageSize = (int)Preferences::get('listPageSize', 50)->data;
$path = route('transactions.index', [$what]);
if (null === $start) { if (null === $start) {
$start = session('start'); $start = session('start');
$end = session('end'); $end = session('end');
@ -183,8 +182,8 @@ class TransactionController extends Controller
$order = 0; $order = 0;
$ids = array_unique($ids); $ids = array_unique($ids);
foreach ($ids as $id) { foreach ($ids as $id) {
$journal = $this->repository->find((int)$id); $journal = $this->repository->findNull((int)$id);
if ($journal && $journal->date->isSameDay($date)) { if (null !== $journal && $journal->date->isSameDay($date)) {
$this->repository->setOrder($journal, $order); $this->repository->setOrder($journal, $order);
++$order; ++$order;
} }

View File

@ -105,7 +105,12 @@ class Authenticate
} }
} catch (QueryException $e) { } catch (QueryException $e) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
throw new FireflyException('It seems the database has not yet been initialized. Did you run the correct upgrade or installation commands?'); throw new FireflyException(
sprintf(
'It seems the database has not yet been initialized. Did you run the correct upgrade or installation commands? Error: %s',
$e->getMessage()
)
);
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
} }

View File

@ -18,6 +18,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @noinspection PhpMethodParametersCountMismatchInspection */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Http\Middleware; namespace FireflyIII\Http\Middleware;
@ -65,6 +66,7 @@ class AuthenticateTwoFactor
return response()->redirectTo(route('login')); return response()->redirectTo(route('login'));
} }
$is2faEnabled = app('preferences')->get('twoFactorAuthEnabled', false)->data; $is2faEnabled = app('preferences')->get('twoFactorAuthEnabled', false)->data;
$has2faSecret = null !== app('preferences')->get('twoFactorAuthSecret'); $has2faSecret = null !== app('preferences')->get('twoFactorAuthSecret');
$is2faAuthed = 'true' === $request->cookie('twoFactorAuthenticated'); $is2faAuthed = 'true' === $request->cookie('twoFactorAuthenticated');

View File

@ -30,12 +30,4 @@ use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
*/ */
class EncryptCookies extends Middleware class EncryptCookies extends Middleware
{ {
/**
* The names of the cookies that should not be encrypted.
*
* @var array
*/
protected $except
= [
];
} }

View File

@ -48,12 +48,12 @@ class Installer
*/ */
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {
if (env('APP_ENV') === 'testing') { if ('testing' === env('APP_ENV')) {
return $next($request); return $next($request);
} }
$url = $request->url(); $url = $request->url();
$strpos = stripos($url, '/install'); $strpos = stripos($url, '/install');
if (!($strpos === false)) { if (!(false === $strpos)) {
Log::debug(sprintf('URL is %s, will NOT run installer middleware', $url)); Log::debug(sprintf('URL is %s, will NOT run installer middleware', $url));
return $next($request); return $next($request);
@ -102,7 +102,7 @@ class Installer
*/ */
protected function isAccessDenied(string $message): bool protected function isAccessDenied(string $message): bool
{ {
return !(stripos($message, 'Access denied') === false); return !(false === stripos($message, 'Access denied'));
} }
/** /**
@ -112,6 +112,6 @@ class Installer
*/ */
protected function noTablesExist(string $message): bool protected function noTablesExist(string $message): bool
{ {
return !(stripos($message, 'Base table or view not found') === false); return !(false === stripos($message, 'Base table or view not found'));
} }
} }

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Middleware; namespace FireflyIII\Http\Middleware;
use Closure; use Closure;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
@ -52,7 +53,9 @@ class IsAdmin
} }
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
if (!$user->hasRole('owner')) { /** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class);
if (!$repository->hasRole($user, 'owner')) {
return response()->redirectTo(route('home')); return response()->redirectTo(route('home'));
} }

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Http\Middleware;
use Closure; use Closure;
use FireflyIII\Exceptions\IsDemoUserException; use FireflyIII\Exceptions\IsDemoUserException;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@ -48,7 +49,9 @@ class IsDemoUser
return $next($request); return $next($request);
} }
if ($user->hasRole('demo')) { /** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class);
if ($repository->hasRole($user, 'demo')) {
$request->session()->flash('info', (string)trans('firefly.not_available_demo_user')); $request->session()->flash('info', (string)trans('firefly.not_available_demo_user'));
$current = $request->url(); $current = $request->url();
$previous = $request->session()->previousUrl(); $previous = $request->session()->previousUrl();

View File

@ -107,7 +107,7 @@ class Range
*/ */
private function loseItAll(Request $request) private function loseItAll(Request $request)
{ {
if (getenv('DB_CONNECTION') === 'sqlite' && getenv('IS_DOCKER') === true) { if ('sqlite' === getenv('DB_CONNECTION') && true === getenv('IS_DOCKER')) {
$request->session()->flash( $request->session()->flash(
'error', 'You seem to be using SQLite in a Docker container. Don\'t do this. If the container restarts all your data will be gone.' 'error', 'You seem to be using SQLite in a Docker container. Don\'t do this. If the container restarts all your data will be gone.'
); );

View File

@ -18,6 +18,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Http\Middleware; namespace FireflyIII\Http\Middleware;

View File

@ -51,11 +51,11 @@ class TrustProxies extends Middleware
{ {
$trustedProxies = env('TRUSTED_PROXIES', null); $trustedProxies = env('TRUSTED_PROXIES', null);
if (false !== $trustedProxies && null !== $trustedProxies && \strlen($trustedProxies) > 0) { if (false !== $trustedProxies && null !== $trustedProxies && \strlen($trustedProxies) > 0) {
if ($trustedProxies === '*' || $trustedProxies === '**') { if ('*' === $trustedProxies || '**' === $trustedProxies) {
$this->proxies = (string)$trustedProxies; $this->proxies = $trustedProxies;
} }
if ($trustedProxies !== '*' && $trustedProxies !== '**') { if ('*' !== $trustedProxies && '**' !== $trustedProxies) {
$this->proxies = explode(',', $trustedProxies); $this->proxies = explode(',', $trustedProxies);
} }
} }

View File

@ -30,12 +30,4 @@ use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
*/ */
class VerifyCsrfToken extends Middleware class VerifyCsrfToken extends Middleware
{ {
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except
= [
];
} }

View File

@ -239,15 +239,15 @@ class JournalFormRequest extends Request
$data = $validator->getData(); $data = $validator->getData();
$type = $data['what'] ?? 'invalid'; $type = $data['what'] ?? 'invalid';
Log::debug(sprintf('Type is %s', $type)); Log::debug(sprintf('Type is %s', $type));
if ($type === 'withdrawal') { if ('withdrawal' === $type) {
$selectedCurrency = (int)($data['amount_currency_id_amount'] ?? 0); $selectedCurrency = (int)($data['amount_currency_id_amount'] ?? 0);
$accountCurrency = (int)($data['source_account_currency'] ?? 0); $accountCurrency = (int)($data['source_account_currency'] ?? 0);
Log::debug(sprintf('Selected currency is %d, account currency is %d', $selectedCurrency, $accountCurrency)); Log::debug(sprintf('Selected currency is %d, account currency is %d', $selectedCurrency, $accountCurrency));
$nativeAmount = (string)($data['native_amount'] ?? ''); $nativeAmount = (string)($data['native_amount'] ?? '');
if ($selectedCurrency !== $accountCurrency && '' === $nativeAmount if ($selectedCurrency !== $accountCurrency && '' === $nativeAmount
&& $selectedCurrency !== 0 && 0 !== $selectedCurrency
&& $accountCurrency !== 0 && 0 !== $accountCurrency
) { ) {
Log::debug('ADD validation error on native_amount'); Log::debug('ADD validation error on native_amount');
$validator->errors()->add('native_amount', trans('validation.numeric_native')); $validator->errors()->add('native_amount', trans('validation.numeric_native'));
@ -257,13 +257,13 @@ class JournalFormRequest extends Request
} }
// same thing for deposits: // same thing for deposits:
if ($type === 'deposit') { if ('deposit' === $type) {
$selectedCurrency = (int)($data['amount_currency_id_amount'] ?? 0); $selectedCurrency = (int)($data['amount_currency_id_amount'] ?? 0);
$accountCurrency = (int)($data['destination_account_currency'] ?? 0); $accountCurrency = (int)($data['destination_account_currency'] ?? 0);
$nativeAmount = (string)($data['native_amount'] ?? ''); $nativeAmount = (string)($data['native_amount'] ?? '');
if ($selectedCurrency !== $accountCurrency && '' === $nativeAmount if ($selectedCurrency !== $accountCurrency && '' === $nativeAmount
&& $selectedCurrency !== 0 && 0 !== $selectedCurrency
&& $accountCurrency !== 0 && 0 !== $accountCurrency
) { ) {
$validator->errors()->add('native_amount', trans('validation.numeric_native')); $validator->errors()->add('native_amount', trans('validation.numeric_native'));
@ -272,7 +272,7 @@ class JournalFormRequest extends Request
} }
// and for transfers // and for transfers
if ($type === 'transfer') { if ('transfer' === $type) {
$sourceCurrency = (int)($data['source_account_currency'] ?? 0); $sourceCurrency = (int)($data['source_account_currency'] ?? 0);
$destinationCurrency = (int)($data['destination_account_currency'] ?? 0); $destinationCurrency = (int)($data['destination_account_currency'] ?? 0);
@ -282,15 +282,15 @@ class JournalFormRequest extends Request
Log::debug(sprintf('Source currency is %d, destination currency is %d', $sourceCurrency, $destinationCurrency)); Log::debug(sprintf('Source currency is %d, destination currency is %d', $sourceCurrency, $destinationCurrency));
if ($sourceCurrency !== $destinationCurrency && '' === $sourceAmount if ($sourceCurrency !== $destinationCurrency && '' === $sourceAmount
&& $sourceCurrency !== 0 && 0 !== $sourceCurrency
&& $destinationCurrency !== 0 && 0 !== $destinationCurrency
) { ) {
$validator->errors()->add('source_amount', trans('validation.numeric_source')); $validator->errors()->add('source_amount', trans('validation.numeric_source'));
} }
if ($sourceCurrency !== $destinationCurrency && '' === $destinationAmount if ($sourceCurrency !== $destinationCurrency && '' === $destinationAmount
&& $sourceCurrency !== 0 && 0 !== $sourceCurrency
&& $destinationCurrency !== 0 && 0 !== $destinationCurrency
) { ) {
$validator->errors()->add('destination_amount', trans('validation.numeric_destination')); $validator->errors()->add('destination_amount', trans('validation.numeric_destination'));
$validator->errors()->add('destination_amount', trans('validation.numeric', ['attribute' => 'destination_amount'])); $validator->errors()->add('destination_amount', trans('validation.numeric', ['attribute' => 'destination_amount']));

View File

@ -18,6 +18,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Http\Requests; namespace FireflyIII\Http\Requests;

View File

@ -174,16 +174,16 @@ class RecurrenceFormRequest extends Request
} }
// if ends after X repetitions, set another rule // if ends after X repetitions, set another rule
if ($this->string('repetition_end') === 'times') { if ('times' === $this->string('repetition_end')) {
$rules['repetitions'] = 'required|numeric|between:0,254'; $rules['repetitions'] = 'required|numeric|between:0,254';
} }
// if foreign amount, currency must be different. // if foreign amount, currency must be different.
if ($this->float('foreign_amount') !== 0.0) { if (0.0 !== $this->float('foreign_amount')) {
$rules['foreign_currency_id'] = 'exists:transaction_currencies,id|different:transaction_currency_id'; $rules['foreign_currency_id'] = 'exists:transaction_currencies,id|different:transaction_currency_id';
} }
// if ends at date X, set another rule. // if ends at date X, set another rule.
if ($this->string('repetition_end') === 'until_date') { if ('until_date' === $this->string('repetition_end')) {
$rules['repeat_until'] = 'required|date|after:' . $tomorrow->format('Y-m-d'); $rules['repeat_until'] = 'required|date|after:' . $tomorrow->format('Y-m-d');
} }
@ -231,7 +231,7 @@ class RecurrenceFormRequest extends Request
'moment' => '', 'moment' => '',
]; ];
if ($value === 'daily') { if ('daily' === $value) {
$return['type'] = $value; $return['type'] = $value;
} }
//monthly,17 //monthly,17

View File

@ -125,8 +125,9 @@ class ReportFormRequest extends Request
$date = new Carbon($parts[1]); $date = new Carbon($parts[1]);
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
} catch (Exception $e) { } catch (Exception $e) {
Log::error(sprintf('"%s" is not a valid date range.', $range)); $error = sprintf('"%s" is not a valid date range: %s', $range, $e->getMessage());
throw new FireflyException(sprintf('"%s" is not a valid date range.', $range)); Log::error($error);
throw new FireflyException($error);
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
} }
@ -172,8 +173,9 @@ class ReportFormRequest extends Request
$date = new Carbon($parts[0]); $date = new Carbon($parts[0]);
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
} catch (Exception $e) { } catch (Exception $e) {
Log::error(sprintf('"%s" is not a valid date range.', $range)); $error = sprintf('"%s" is not a valid date range: %s', $range, $e->getMessage());
throw new FireflyException(sprintf('"%s" is not a valid date range.', $range)); Log::error($error);
throw new FireflyException($error);
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
} }
} }

View File

@ -37,10 +37,10 @@ class Request extends FormRequest
*/ */
public function boolean(string $field): bool public function boolean(string $field): bool
{ {
if ((string)$this->input($field) === 'true') { if ('true' === (string)$this->input($field)) {
return true; return true;
} }
if ((string)$this->input($field) === 'false') { if ('false' === (string)$this->input($field)) {
return false; return false;
} }

View File

@ -67,7 +67,7 @@ class RuleFormRequest extends Request
$data['rule-triggers'][] = [ $data['rule-triggers'][] = [
'name' => $value, 'name' => $value,
'value' => $triggerValues[$index] ?? '', 'value' => $triggerValues[$index] ?? '',
'stop-processing' => (int)($triggerStop[$index] ?? 0) === 1, 'stop-processing' => 1 === (int)($triggerStop[$index] ?? 0),
]; ];
} }
} }
@ -77,7 +77,7 @@ class RuleFormRequest extends Request
$data['rule-actions'][] = [ $data['rule-actions'][] = [
'name' => $value, 'name' => $value,
'value' => $actionValues[$index] ?? '', 'value' => $actionValues[$index] ?? '',
'stop-processing' => (int)($actionStop[$index] ?? 0) === 1, 'stop-processing' => 1 === (int)($actionStop[$index] ?? 0),
]; ];
} }
} }

View File

@ -154,7 +154,7 @@ class SplitJournalFormRequest extends Request
$transactions = $data['transactions'] ?? []; $transactions = $data['transactions'] ?? [];
/** @var array $array */ /** @var array $array */
foreach ($transactions as $array) { foreach ($transactions as $array) {
if ($array['destination_id'] !== null && $array['source_id'] !== null && $array['destination_id'] === $array['source_id']) { if (null !== $array['destination_id'] && null !== $array['source_id'] && $array['destination_id'] === $array['source_id']) {
$validator->errors()->add('journal_source_id', trans('validation.source_equals_destination')); $validator->errors()->add('journal_source_id', trans('validation.source_equals_destination'));
$validator->errors()->add('journal_destination_id', trans('validation.source_equals_destination')); $validator->errors()->add('journal_destination_id', trans('validation.source_equals_destination'));
} }

View File

@ -68,13 +68,13 @@ class TagFormRequest extends Request
/** /**
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
/** @var TagRepositoryInterface $repository */ /** @var TagRepositoryInterface $repository */
$repository = app(TagRepositoryInterface::class); $repository = app(TagRepositoryInterface::class);
$idRule = ''; $idRule = '';
$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag'; $tagRule = 'required|min:1|uniqueObjectForUser:tags,tag';
if (null !== $repository->find((int)$this->get('id'))->id) { if (null !== $repository->findNull((int)$this->get('id'))) {
$idRule = 'belongsToUser:tags'; $idRule = 'belongsToUser:tags';
$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag,' . $this->get('id'); $tagRule = 'required|min:1|uniqueObjectForUser:tags,tag,' . $this->get('id');
} }

View File

@ -59,6 +59,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* *
* @property int $id * @property int $id
* @property string $email * @property string $email
* @property bool $isAdmin used in admin user controller.
* @property bool $has2FA used in admin user controller.
* @property array $prefs used in admin user controller.
*/ */
class User extends Authenticatable class User extends Authenticatable
{ {