mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-07 06:31:22 +00:00
Improve code quality and fix test coverage.
This commit is contained in:
@@ -649,9 +649,10 @@ class BudgetController extends Controller
|
||||
*/
|
||||
private function getPeriodOverview(): Collection
|
||||
{
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
$repository = app(JournalRepositoryInterface::class);
|
||||
$first = $repository->first();
|
||||
$start = $first->date ?? new Carbon;
|
||||
$first = $repository->firstNull();
|
||||
$start = null === $first ? new Carbon : $first->date;
|
||||
$range = Preferences::get('viewRange', '1M')->data;
|
||||
$start = app('navigation')->startOfPeriod($start, $range);
|
||||
$end = app('navigation')->endOfX(new Carbon, $range, null);
|
||||
|
||||
@@ -128,8 +128,8 @@ class TransactionController extends Controller
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
|
||||
$path = route('transactions.index.all', [$what]);
|
||||
$first = $this->repository->first();
|
||||
$start = $first->date ?? new Carbon;
|
||||
$first = $this->repository->firstNull();
|
||||
$start = null === $first ? new Carbon : $first->date;
|
||||
$end = new Carbon;
|
||||
$subTitle = trans('firefly.all_' . $what);
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ class Range
|
||||
$first = Carbon::now()->startOfYear();
|
||||
|
||||
if (null !== $journal) {
|
||||
$first = $journal->date;
|
||||
$first = $journal->date ?? $first;
|
||||
}
|
||||
Session::put('first', $first);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class Sandstorm
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
if (1 === $count && 0 === \strlen($userId)) {
|
||||
if (1 === $count && '' === $userId) {
|
||||
// login but indicate anonymous
|
||||
$user = User::first();
|
||||
Auth::guard($guard)->login($user);
|
||||
@@ -111,7 +111,7 @@ class Sandstorm
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
if (0 === $count && 0 === \strlen($userId)) {
|
||||
if (0 === $count && '' === $userId) {
|
||||
throw new FireflyException('The first visit to a new Firefly III administration cannot be by a guest user.');
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ class Sandstorm
|
||||
}
|
||||
// if in Sandstorm, user logged in, still must check if user is anon.
|
||||
$userId = (string)$request->header('X-Sandstorm-User-Id');
|
||||
if (\strlen($userId) === 0) {
|
||||
if ('' === $userId) {
|
||||
View::share('SANDSTORM_ANON', true);
|
||||
|
||||
return $next($request);
|
||||
|
||||
Reference in New Issue
Block a user