Refactor references to static facades. Improve budget controller code.

This commit is contained in:
James Cole
2018-07-14 16:08:34 +02:00
parent b8699422c8
commit 89834baf01
41 changed files with 284 additions and 246 deletions

View File

@@ -29,7 +29,6 @@ use FireflyIII\Http\Requests\AccountFormRequest;
use FireflyIII\Models\AccountType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Http\Request;
use Preferences;
/**
*
@@ -103,11 +102,11 @@ class CreateController extends Controller
app('preferences')->mark();
// update preferences if necessary:
$frontPage = Preferences::get('frontPageAccounts', [])->data;
$frontPage = app('preferences')->get('frontPageAccounts', [])->data;
if (AccountType::ASSET === $account->accountType->type && \count($frontPage) > 0) {
// @codeCoverageIgnoreStart
$frontPage[] = $account->id;
Preferences::set('frontPageAccounts', $frontPage);
app('preferences')->set('frontPageAccounts', $frontPage);
// @codeCoverageIgnoreEnd
}
// redirect to previous URL.

View File

@@ -29,7 +29,6 @@ use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Preferences;
/**
*
@@ -75,7 +74,7 @@ class IndexController extends Controller
$collection = $this->repository->getAccountsByType($types);
$total = $collection->count();
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$accounts = $collection->slice(($page - 1) * $pageSize, $pageSize);
unset($collection);
/** @var Carbon $start */

View File

@@ -38,7 +38,6 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Services\Internal\Update\CurrencyUpdateService;
use Log;
use Preferences;
/**
* Class ReconcileController.
@@ -138,7 +137,7 @@ class ReconcileController extends Controller
}
// no start or end:
$range = Preferences::get('viewRange', '1M')->data;
$range = app('preferences')->get('viewRange', '1M')->data;
// get start and end
if (null === $start && null === $end) {

View File

@@ -36,7 +36,6 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Preferences;
use View;
/**
@@ -100,7 +99,7 @@ class ShowController extends Controller
$today = new Carbon;
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $account->accountType->type));
$page = (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$currencyId = (int)$this->repository->getMetaValue($account, 'currency_id');
$currency = $this->currencyRepos->findNull($currencyId);
if (0 === $currencyId) {
@@ -146,7 +145,7 @@ class ShowController extends Controller
$start = $this->repository->oldestJournalDate($account);
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
$page = (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$currencyId = (int)$this->repository->getMetaValue($account, 'currency_id');
$currency = $this->currencyRepos->findNull($currencyId);
if (0 === $currencyId) {
@@ -187,7 +186,7 @@ class ShowController extends Controller
*/
private function getPeriodOverview(Account $account, ?Carbon $date): Collection
{
$range = Preferences::get('viewRange', '1M')->data;
$range = app('preferences')->get('viewRange', '1M')->data;
$start = $this->repository->oldestJournalDate($account);
$end = $date ?? new Carbon;
if ($end < $start) {

View File

@@ -29,7 +29,6 @@ use FireflyIII\Http\Requests\UserFormRequest;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User;
use Log;
use Preferences;
/**
* Class UserController.
@@ -121,7 +120,7 @@ class UserController extends Controller
$users->each(
function (User $user) use ($repository) {
$list = ['twoFactorAuthEnabled', 'twoFactorAuthSecret'];
$preferences = Preferences::getArrayForUser($user, $list);
$preferences = app('preferences')->getArrayForUser($user, $list);
$user->isAdmin = $repository->hasRole($user, 'owner');
$is2faEnabled = 1 === $preferences['twoFactorAuthEnabled'];
$has2faSecret = null !== $preferences['twoFactorAuthSecret'];

View File

@@ -29,7 +29,6 @@ use FireflyIII\User;
use Illuminate\Cookie\CookieJar;
use Illuminate\Http\Request;
use Log;
use Preferences;
/**
* Class TwoFactorController.
@@ -49,12 +48,12 @@ class TwoFactorController extends Controller
$user = auth()->user();
// to make sure the validator in the next step gets the secret, we push it in session
$secretPreference = Preferences::get('twoFactorAuthSecret', null);
$secretPreference = app('preferences')->get('twoFactorAuthSecret', null);
$secret = null === $secretPreference ? null : $secretPreference->data;
$title = (string)trans('firefly.two_factor_title');
// make sure the user has two factor configured:
$has2FA = Preferences::get('twoFactorAuthEnabled', false)->data;
$has2FA = app('preferences')->get('twoFactorAuthEnabled', false)->data;
if (null === $has2FA || false === $has2FA) {
return redirect(route('index'));
}

View File

@@ -36,10 +36,8 @@ use Illuminate\Support\Collection;
use League\Fractal\Manager;
use League\Fractal\Resource\Item;
use League\Fractal\Serializer\DataArraySerializer;
use Preferences;
use Symfony\Component\HttpFoundation\ParameterBag;
use URL;
use View;
/**
* Class BillController.
@@ -65,7 +63,7 @@ class BillController extends Controller
$maxFileSize = app('steam')->phpBytes(ini_get('upload_max_filesize'));
$maxPostSize = app('steam')->phpBytes(ini_get('post_max_size'));
$uploadSize = min($maxFileSize, $maxPostSize);
View::share('uploadSize', $uploadSize);
app('view')->share('uploadSize', $uploadSize);
$this->middleware(
function ($request, $next) {
@@ -186,7 +184,7 @@ class BillController extends Controller
{
$start = session('start');
$end = session('end');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$paginator = $this->billRepository->getPaginator($pageSize);
$parameters = new ParameterBag();
$parameters->set('start', $start);
@@ -269,7 +267,7 @@ class BillController extends Controller
$end = session('end');
$year = $start->year;
$page = (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$yearAverage = $this->billRepository->getYearAverage($bill, $start);
$overallAverage = $this->billRepository->getOverallAverage($bill);
$manager = new Manager();

View File

@@ -32,13 +32,12 @@ use FireflyIII\Models\Budget;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use FireflyIII\Support\Http\Controllers\DateCalculation;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Log;
use Preferences;
use View;
/**
*
@@ -46,6 +45,7 @@ use View;
*/
class AmountController extends Controller
{
use DateCalculation;
/** @var BudgetRepositoryInterface */
private $repository;
@@ -56,7 +56,7 @@ class AmountController extends Controller
{
parent::__construct();
View::share('hideBudgets', true);
app('view')->share('hideBudgets', true);
$this->middleware(
function ($request, $next) {
@@ -79,53 +79,36 @@ class AmountController extends Controller
*/
public function amount(Request $request, BudgetRepositoryInterface $repository, Budget $budget): JsonResponse
{
$amount = (string)$request->get('amount');
$start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
$end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
$budgetLimit = $this->repository->updateLimitAmount($budget, $start, $end, $amount);
$largeDiff = false;
$warnText = '';
$days = 0;
$daysInMonth = 0;
if (0 === bccomp($amount, '0')) {
$budgetLimit = null;
}
$amount = (string)$request->get('amount');
$start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
$end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
$budgetLimit = $this->repository->updateLimitAmount($budget, $start, $end, $amount);
$spent = $repository->spentInPeriod(new Collection([$budget]), new Collection, $start, $end);
$currency = app('amount')->getDefaultCurrency();
$left = app('amount')->formatAnything($currency, bcadd($amount, $spent), true);
$largeDiff = false;
$warnText = '';
$leftPerDay = null;
$periodLength = $start->diffInDays($end);
$dayDifference = $this->getDayDifference($start, $end);
// if today is between start and end, use the diff in days between end and today (days left)
// otherwise, use diff between start and end.
$today = new Carbon;
Log::debug(sprintf('Start is %s, end is %s, today is %s', $start->format('Y-m-d'), $end->format('Y-m-d'), $today->format('Y-m-d')));
if ($today->gte($start) && $today->lte($end)) {
$days = $end->diffInDays($today);
$daysInMonth = $start->diffInDays($today);
}
if ($today->lte($start) || $today->gte($end)) {
$days = $start->diffInDays($end);
$daysInMonth = $start->diffInDays($end);
}
$days = 0 === $days ? 1 : $days;
$daysInMonth = 0 === $daysInMonth ? 1 : $daysInMonth;
// calculate left in budget:
$spent = $repository->spentInPeriod(new Collection([$budget]), new Collection, $start, $end);
$currency = app('amount')->getDefaultCurrency();
$left = app('amount')->formatAnything($currency, bcadd($amount, $spent), true);
$leftPerDay = 'none';
// is user has money left, calculate.
/*
* If the user budgets ANY amount per day for this budget (anything but zero)
* Firefly III calculates how much he could spend per day.
*/
if (1 === bccomp(bcadd($amount, $spent), '0')) {
$leftPerDay = app('amount')->formatAnything($currency, bcdiv(bcadd($amount, $spent), (string)$days), true);
$leftPerDay = app('amount')->formatAnything($currency, bcdiv(bcadd($amount, $spent), (string)$dayDifference), true);
}
// over or under budgeting, compared to previous budgets?
/*
* Get the average amount of money the user budgets for this budget.
* And calculate the same for the current amount.
*
* If the difference is very large, give the user a notification.
*/
$average = $this->repository->budgetedPerDay($budget);
// current average per day:
$diff = $start->diffInDays($end);
$current = $amount;
if ($diff > 0) {
$current = bcdiv($amount, (string)$diff);
}
$current = bcdiv($amount, (string)$periodLength);
if (bccomp(bcmul('1.1', $average), $current) === -1) {
$largeDiff = true;
$warnText = (string)trans(
@@ -150,8 +133,6 @@ class AmountController extends Controller
'large_diff' => $largeDiff,
'left_per_day' => $leftPerDay,
'warn_text' => $warnText,
'daysInMonth' => $daysInMonth,
]
);
}
@@ -187,7 +168,7 @@ class AmountController extends Controller
'suggested' => '0',
];
$currency = app('amount')->getDefaultCurrency();
$range = Preferences::get('viewRange', '1M')->data;
$range = app('preferences')->get('viewRange', '1M')->data;
/** @var Carbon $begin */
$begin = app('navigation')->subtractPeriod($start, $range, 3);
@@ -272,5 +253,4 @@ class AmountController extends Controller
return view('budgets.income', compact('available', 'start', 'end', 'page'));
}
}

View File

@@ -29,7 +29,6 @@ use FireflyIII\Http\Requests\BudgetFormRequest;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use View;
/**
* Class CreateController
@@ -46,7 +45,7 @@ class CreateController extends Controller
{
parent::__construct();
View::share('hideBudgets', true);
app('view')->share('hideBudgets', true);
$this->middleware(
function ($request, $next) {

View File

@@ -28,7 +28,6 @@ use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Budget;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use Illuminate\Http\Request;
use View;
/**
*
@@ -46,7 +45,7 @@ class DeleteController extends Controller
{
parent::__construct();
View::share('hideBudgets', true);
app('view')->share('hideBudgets', true);
$this->middleware(
function ($request, $next) {

View File

@@ -30,7 +30,6 @@ use FireflyIII\Models\Budget;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use View;
/**
*
@@ -48,7 +47,7 @@ class EditController extends Controller
{
parent::__construct();
View::share('hideBudgets', true);
app('view')->share('hideBudgets', true);
$this->middleware(
function ($request, $next) {

View File

@@ -28,11 +28,10 @@ use Carbon\Carbon;
use Exception;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Support\Http\Controllers\DateCalculation;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Log;
use Preferences;
use View;
/**
*
@@ -41,6 +40,7 @@ use View;
class IndexController extends Controller
{
use DateCalculation;
/** @var BudgetRepositoryInterface */
private $repository;
@@ -51,7 +51,7 @@ class IndexController extends Controller
{
parent::__construct();
View::share('hideBudgets', true);
app('view')->share('hideBudgets', true);
$this->middleware(
function ($request, $next) {
@@ -73,13 +73,13 @@ class IndexController extends Controller
*/
public function index(Request $request, string $moment = null)
{
$range = Preferences::get('viewRange', '1M')->data;
$start = session('start', new Carbon);
$end = session('end', new Carbon);
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$days = 0;
$daysInMonth = 0;
$range = app('preferences')->get('viewRange', '1M')->data;
$start = session('start', new Carbon);
$end = session('end', new Carbon);
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$days = 0;
// make date if present:
if (null !== $moment || '' !== (string)$moment) {
@@ -96,15 +96,12 @@ class IndexController extends Controller
// otherwise, use diff between start and end.
$today = new Carbon;
if ($today->gte($start) && $today->lte($end)) {
$days = $end->diffInDays($today);
$daysInMonth = $start->diffInDays($today);
$days = $end->diffInDays($today);
}
if ($today->lte($start) || $today->gte($end)) {
$days = $start->diffInDays($end);
$daysInMonth = $start->diffInDays($end);
$days = $start->diffInDays($end);
}
$days = 0 === $days ? 1 : $days;
$daysInMonth = 0 === $daysInMonth ? 1 : $daysInMonth;
$days = 0 === $days ? 1 : $days;
$next = clone $end;
@@ -113,6 +110,7 @@ class IndexController extends Controller
$prev->subDay();
$prev = app('navigation')->startOfPeriod($prev, $range);
$this->repository->cleanupBudgets();
$daysPassed = $this->getDaysPassedInPeriod($start, $end);
$allBudgets = $this->repository->getActiveBudgets();
$total = $allBudgets->count();
$budgets = $allBudgets->slice(($page - 1) * $pageSize, $pageSize);
@@ -165,10 +163,14 @@ class IndexController extends Controller
return view(
'budgets.index', compact(
'available', 'currentMonth', 'next', 'nextText', 'prev', 'allBudgets', 'prevText', 'periodStart', 'periodEnd', 'days', 'page',
'budgetInformation', 'daysInMonth',
'budgetInformation', 'daysPassed',
'inactive', 'budgets', 'spent', 'budgeted', 'previousLoop', 'nextLoop', 'start', 'end'
)
);
}
}

View File

@@ -36,8 +36,6 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Preferences;
use View;
/**
*
@@ -56,7 +54,7 @@ class ShowController extends Controller
{
parent::__construct();
View::share('hideBudgets', true);
app('view')->share('hideBudgets', true);
$this->middleware(
function ($request, $next) {
@@ -80,7 +78,7 @@ class ShowController extends Controller
{
// default values:
$moment = $moment ?? '';
$range = Preferences::get('viewRange', '1M')->data;
$range = app('preferences')->get('viewRange', '1M')->data;
$start = null;
$end = null;
$periods = new Collection;
@@ -117,7 +115,7 @@ class ShowController extends Controller
}
$page = (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
@@ -141,7 +139,7 @@ class ShowController extends Controller
$start = session('first', Carbon::create()->startOfYear());
$end = new Carbon;
$page = (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$limits = $this->getLimits($budget, $start, $end);
$repetition = null;
@@ -172,7 +170,7 @@ class ShowController extends Controller
}
$page = (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$subTitle = trans(
'firefly.budget_in_period',
[
@@ -239,7 +237,7 @@ class ShowController extends Controller
$repository = app(JournalRepositoryInterface::class);
$first = $repository->firstNull();
$start = null === $first ? new Carbon : $first->date;
$range = Preferences::get('viewRange', '1M')->data;
$range = app('preferences')->get('viewRange', '1M')->data;
$start = app('navigation')->startOfPeriod($start, $range);
$end = app('navigation')->endOfX(new Carbon, $range, null);
$entries = new Collection;

View File

@@ -37,7 +37,6 @@ use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Log;
use Preferences;
/**
* Class CategoryController.
@@ -146,7 +145,7 @@ class CategoryController extends Controller
public function index(Request $request)
{
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$collection = $this->repository->getCategories();
$total = $collection->count();
$collection = $collection->slice(($page - 1) * $pageSize, $pageSize);
@@ -174,12 +173,12 @@ class CategoryController extends Controller
{
// default values:
$moment = $moment ?? '';
$range = Preferences::get('viewRange', '1M')->data;
$range = app('preferences')->get('viewRange', '1M')->data;
$start = null;
$end = null;
$periods = new Collection;
$page = (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
Log::debug('Start of noCategory()');
// prep for "all" view.
if ('all' === $moment) {
@@ -242,8 +241,8 @@ class CategoryController extends Controller
$subTitle = $category->name;
$subTitleIcon = 'fa-bar-chart';
$page = (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$range = Preferences::get('viewRange', '1M')->data;
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$range = app('preferences')->get('viewRange', '1M')->data;
$start = null;
$end = null;
$periods = new Collection;
@@ -362,7 +361,7 @@ class CategoryController extends Controller
private function getNoCategoryPeriodOverview(Carbon $theDate): Collection
{
Log::debug(sprintf('Now in getNoCategoryPeriodOverview(%s)', $theDate->format('Y-m-d')));
$range = Preferences::get('viewRange', '1M')->data;
$range = app('preferences')->get('viewRange', '1M')->data;
$first = $this->journalRepos->firstNull();
$start = null === $first ? new Carbon : $first->date;
$end = $theDate ?? new Carbon;
@@ -447,7 +446,7 @@ class CategoryController extends Controller
*/
private function getPeriodOverview(Category $category, Carbon $date): Collection
{
$range = Preferences::get('viewRange', '1M')->data;
$range = app('preferences')->get('viewRange', '1M')->data;
$first = $this->journalRepos->firstNull();
$start = null === $first ? new Carbon : $first->date;
$end = $date ?? new Carbon;

View File

@@ -39,7 +39,6 @@ use FireflyIII\Support\CacheProperties;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Collection;
use Log;
use Preferences;
/** checked
* Class AccountController.
@@ -231,7 +230,7 @@ class AccountController extends Controller
$end = clone session('end', Carbon::now()->endOfMonth());
$defaultSet = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray();
Log::debug('Default set is ', $defaultSet);
$frontPage = Preferences::get('frontPageAccounts', $defaultSet);
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
Log::debug('Frontpage preference set is ', $frontPage->data);

View File

@@ -32,7 +32,6 @@ use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Collection;
use Preferences;
/**
* Class CategoryController.
@@ -77,7 +76,7 @@ class CategoryController extends Controller
$start = new Carbon; // @codeCoverageIgnore
}
$range = Preferences::get('viewRange', '1M')->data;
$range = app('preferences')->get('viewRange', '1M')->data;
$start = app('navigation')->startOfPeriod($start, $range);
$end = new Carbon;
$accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
@@ -283,7 +282,7 @@ class CategoryController extends Controller
*/
public function specificPeriod(Category $category, Carbon $date): JsonResponse
{
$range = Preferences::get('viewRange', '1M')->data;
$range = app('preferences')->get('viewRange', '1M')->data;
$start = app('navigation')->startOfPeriod($date, $range);
$end = app('navigation')->endOfPeriod($date, $range);
$data = $this->makePeriodChart($category, $start, $end);

View File

@@ -27,7 +27,6 @@ use FireflyIII\Models\AccountType;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Support\Facades\Preferences;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
@@ -35,7 +34,6 @@ use Illuminate\Routing\Controller as BaseController;
use Log;
use Route;
use URL;
use View;
/**
* Class Controller.
@@ -59,17 +57,17 @@ class Controller extends BaseController
public function __construct()
{
// for transaction lists:
View::share('hideBudgets', false);
View::share('hideCategories', false);
View::share('hideBills', false);
View::share('hideTags', false);
app('view')->share('hideBudgets', false);
app('view')->share('hideCategories', false);
app('view')->share('hideBills', false);
app('view')->share('hideTags', false);
// is site a demo site?
$isDemoSite = FireflyConfig::get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
View::share('IS_DEMO_SITE', $isDemoSite);
View::share('DEMO_USERNAME', env('DEMO_USERNAME', ''));
View::share('DEMO_PASSWORD', env('DEMO_PASSWORD', ''));
View::share('FF_VERSION', config('firefly.version'));
app('view')->share('IS_DEMO_SITE', $isDemoSite);
app('view')->share('DEMO_USERNAME', env('DEMO_USERNAME', ''));
app('view')->share('DEMO_PASSWORD', env('DEMO_PASSWORD', ''));
app('view')->share('FF_VERSION', config('firefly.version'));
$this->middleware(
function ($request, $next) {
@@ -93,17 +91,17 @@ class Controller extends BaseController
// either must be array and either must be > 0
if ((\is_array($intro) || \is_array($specialIntro)) && (\count($intro) > 0 || \count($specialIntro) > 0)) {
$shownDemo = Preferences::get($key, false)->data;
$shownDemo = app('preferences')->get($key, false)->data;
Log::debug(sprintf('Check if user has already seen intro with key "%s". Result is %d', $key, $shownDemo));
}
// share language
$language = Preferences::get('language', config('firefly.default_language', 'en_US'))->data;
$language = app('preferences')->get('language', config('firefly.default_language', 'en_US'))->data;
View::share('language', $language);
View::share('shownDemo', $shownDemo);
View::share('current_route_name', $page);
View::share('original_route_name', Route::currentRouteName());
app('view')->share('language', $language);
app('view')->share('shownDemo', $shownDemo);
app('view')->share('current_route_name', $page);
app('view')->share('original_route_name', Route::currentRouteName());
}
return $next($request);

View File

@@ -31,7 +31,6 @@ use FireflyIII\User;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Log;
use Preferences;
use View;
/**
@@ -100,7 +99,7 @@ class CurrencyController extends Controller
*/
public function defaultCurrency(Request $request, TransactionCurrency $currency)
{
Preferences::set('currencyPreference', $currency->code);
app('preferences')->set('currencyPreference', $currency->code);
app('preferences')->mark();
$request->session()->flash('success', trans('firefly.new_default_currency', ['name' => $currency->name]));
@@ -215,7 +214,7 @@ class CurrencyController extends Controller
/** @var User $user */
$user = auth()->user();
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$collection = $this->repository->get();
$total = $collection->count();
$collection = $collection->sortBy(
@@ -227,7 +226,7 @@ class CurrencyController extends Controller
$currencies = new LengthAwarePaginator($collection, $total, $pageSize, $page);
$currencies->setPath(route('currencies.index'));
$defaultCurrency = $this->repository->getCurrencyByPreference(Preferences::get('currencyPreference', config('firefly.default_currency', 'EUR')));
$defaultCurrency = $this->repository->getCurrencyByPreference(app('preferences')->get('currencyPreference', config('firefly.default_currency', 'EUR')));
$isOwner = true;
if (!$this->userRepository->hasRole($user, 'owner')) {
$request->session()->flash('info', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')]));

View File

@@ -32,7 +32,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\ExportJob\ExportJobRepositoryInterface;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response as LaravelResponse;
use Preferences;
/**
* Class ExportController.
@@ -118,7 +117,7 @@ class ExportController extends Controller
// does the user have shared accounts?
$formats = array_keys(config('firefly.export_formats'));
$defaultFormat = Preferences::get('export_format', config('firefly.default_export_format'))->data;
$defaultFormat = app('preferences')->get('export_format', config('firefly.default_export_format'))->data;
$first = session('first')->format('Y-m-d');
$today = Carbon::create()->format('Y-m-d');

View File

@@ -25,7 +25,6 @@ namespace FireflyIII\Http\Controllers;
use FireflyIII\Helpers\Help\HelpInterface;
use Illuminate\Http\JsonResponse;
use Log;
use Preferences;
/**
* Class HelpController.
@@ -58,7 +57,7 @@ class HelpController extends Controller
*/
public function show(string $route): JsonResponse
{
$language = Preferences::get('language', config('firefly.default_language', 'en_US'))->data;
$language = app('preferences')->get('language', config('firefly.default_language', 'en_US'))->data;
$html = $this->getHelpText($route, $language);
return response()->json(['html' => $html]);

View File

@@ -36,7 +36,6 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Log;
use Preferences;
use View;
/**
@@ -111,7 +110,7 @@ class HomeController extends Controller
}
$subTitle = trans('firefly.welcomeBack');
$transactions = [];
$frontPage = Preferences::get(
$frontPage = app('preferences')->get(
'frontPageAccounts',
$repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray()
);

View File

@@ -31,7 +31,6 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Log;
use Preferences;
/**
* Class JavascriptController.
@@ -47,7 +46,7 @@ class JavascriptController extends Controller
public function accounts(AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository): Response
{
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$preference = Preferences::get('currencyPreference', config('firefly.default_currency', 'EUR'));
$preference = app('preferences')->get('currencyPreference', config('firefly.default_currency', 'EUR'));
/** @noinspection NullPointerExceptionInspection */
$default = $currencyRepository->findByCodeNull($preference->data);
@@ -114,7 +113,7 @@ class JavascriptController extends Controller
$accounting = app('amount')->getJsConfig($localeconv);
$localeconv = localeconv();
$localeconv['frac_digits'] = $currency->decimal_places;
$pref = Preferences::get('language', config('firefly.default_language', 'en_US'));
$pref = app('preferences')->get('language', config('firefly.default_language', 'en_US'));
/** @noinspection NullPointerExceptionInspection */
$lang = $pref->data;
$dateRange = $this->getDateRangeConfig();
@@ -140,7 +139,7 @@ class JavascriptController extends Controller
*/
private function getDateRangeConfig(): array
{
$viewRange = Preferences::get('viewRange', '1M')->data;
$viewRange = app('preferences')->get('viewRange', '1M')->data;
$start = session('start');
$end = session('end');
$first = session('first');

View File

@@ -22,7 +22,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Json;
use FireflyIII\Support\Facades\Preferences;
use Illuminate\Http\JsonResponse;
use Log;
@@ -104,7 +103,7 @@ class IntroController
$key .= '_' . $specialPage;
}
Log::debug(sprintf('Going to mark the following route as NOT done: %s with special "%s" (%s)', $route, $specialPage, $key));
Preferences::set($key, false);
app('preferences')->set($key, false);
return response()->json(['message' => trans('firefly.intro_boxes_after_refresh')]);
}
@@ -123,7 +122,7 @@ class IntroController
$key .= '_' . $specialPage;
}
Log::debug(sprintf('Going to mark the following route as done: %s with special "%s" (%s)', $route, $specialPage, $key));
Preferences::set($key, true);
app('preferences')->set($key, true);
return response()->json(['result' => sprintf('Reported demo watched for route "%s".', $route)]);
}

View File

@@ -27,7 +27,6 @@ use FireflyIII\Http\Requests\NewUserFormRequest;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use Preferences;
use View;
/**
@@ -89,7 +88,7 @@ class NewUserController extends Controller
}
// set language preference:
Preferences::set('language', $language);
app('preferences')->set('language', $language);
// Store currency preference from input:
$currency = $currencyRepository->findNull((int)$request->input('amount_currency_id_bank_balance'));
@@ -108,7 +107,7 @@ class NewUserController extends Controller
$this->createCashWalletAccount($currency, $language);
// store currency preference:
Preferences::set('currencyPreference', $currency->code);
app('preferences')->set('currencyPreference', $currency->code);
app('preferences')->mark();
// set default optional fields:
@@ -123,7 +122,7 @@ class NewUserController extends Controller
'notes' => true,
'attachments' => true,
];
Preferences::set('transaction_journal_optional_fields', $visibleFields);
app('preferences')->set('transaction_journal_optional_fields', $visibleFields);
session()->flash('success', (string)trans('firefly.stored_new_accounts_new_user'));
app('preferences')->mark();

View File

@@ -36,7 +36,6 @@ use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Log;
use Preferences;
use Symfony\Component\HttpFoundation\ParameterBag;
/**
@@ -220,7 +219,7 @@ class PiggyBankController extends Controller
$collection = $this->piggyRepos->getPiggyBanks();
$total = $collection->count();
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$accounts = [];
/** @var Carbon $end */
$end = session('end', Carbon::now()->endOfMonth());

View File

@@ -35,7 +35,6 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
use InvalidArgumentException;
use View;
/**
* Class ReportController.
@@ -89,8 +88,8 @@ class ReportController extends Controller
$attributes = $request->get('attributes') ?? [];
$attributes = $this->parseAttributes($attributes);
View::share('start', $attributes['startDate']);
View::share('end', $attributes['endDate']);
app('view')->share('start', $attributes['startDate']);
app('view')->share('end', $attributes['endDate']);
switch ($attributes['location']) {
default:

View File

@@ -25,7 +25,6 @@ namespace FireflyIII\Http\Controllers;
use FireflyIII\Models\AccountType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Http\Request;
use Preferences;
/**
* Class PreferencesController.
@@ -57,16 +56,16 @@ class PreferencesController extends Controller
public function index(AccountRepositoryInterface $repository)
{
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$viewRangePref = Preferences::get('viewRange', '1M');
$viewRangePref = app('preferences')->get('viewRange', '1M');
/** @noinspection NullPointerExceptionInspection */
$viewRange = $viewRangePref->data;
$frontPageAccounts = Preferences::get('frontPageAccounts', []);
$language = Preferences::get('language', config('firefly.default_language', 'en_US'))->data;
$listPageSize = Preferences::get('listPageSize', 50)->data;
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
$fiscalYearStartStr = Preferences::get('fiscalYearStart', '01-01')->data;
$frontPageAccounts = app('preferences')->get('frontPageAccounts', []);
$language = app('preferences')->get('language', config('firefly.default_language', 'en_US'))->data;
$listPageSize = app('preferences')->get('listPageSize', 50)->data;
$customFiscalYear = app('preferences')->get('customFiscalYear', 0)->data;
$fiscalYearStartStr = app('preferences')->get('fiscalYearStart', '01-01')->data;
$fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr;
$tjOptionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
$tjOptionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
return view(
'preferences.index',
@@ -96,11 +95,11 @@ class PreferencesController extends Controller
foreach ($request->get('frontPageAccounts') as $id) {
$frontPageAccounts[] = (int)$id;
}
Preferences::set('frontPageAccounts', $frontPageAccounts);
app('preferences')->set('frontPageAccounts', $frontPageAccounts);
}
// view range:
Preferences::set('viewRange', $request->get('viewRange'));
app('preferences')->set('viewRange', $request->get('viewRange'));
// forget session values:
session()->forget('start');
session()->forget('end');
@@ -109,20 +108,20 @@ class PreferencesController extends Controller
// custom fiscal year
$customFiscalYear = 1 === (int)$request->get('customFiscalYear');
$fiscalYearStart = date('m-d', strtotime((string)$request->get('fiscalYearStart')));
Preferences::set('customFiscalYear', $customFiscalYear);
Preferences::set('fiscalYearStart', $fiscalYearStart);
app('preferences')->set('customFiscalYear', $customFiscalYear);
app('preferences')->set('fiscalYearStart', $fiscalYearStart);
// save page size:
Preferences::set('listPageSize', 50);
app('preferences')->set('listPageSize', 50);
$listPageSize = (int)$request->get('listPageSize');
if ($listPageSize > 0 && $listPageSize < 1337) {
Preferences::set('listPageSize', $listPageSize);
app('preferences')->set('listPageSize', $listPageSize);
}
// language:
$lang = $request->get('language');
if (array_key_exists($lang, config('firefly.languages'))) {
Preferences::set('language', $lang);
app('preferences')->set('language', $lang);
}
// optional fields for transactions:
@@ -138,7 +137,7 @@ class PreferencesController extends Controller
'notes' => isset($setOptions['notes']),
'attachments' => isset($setOptions['attachments']),
];
Preferences::set('transaction_journal_optional_fields', $optionalTj);
app('preferences')->set('transaction_journal_optional_fields', $optionalTj);
session()->flash('success', (string)trans('firefly.saved_preferences'));
app('preferences')->mark();

View File

@@ -44,7 +44,6 @@ use Laravel\Passport\ClientRepository;
use Laravel\Passport\Passport;
use Log;
use phpseclib\Crypt\RSA;
use Preferences;
/**
* Class ProfileController.
@@ -125,7 +124,7 @@ class ProfileController extends Controller
{
// find preference with this token value.
/** @var Collection $set */
$set = Preferences::findByName('email_change_confirm_token');
$set = app('preferences')->findByName('email_change_confirm_token');
$user = null;
Log::debug(sprintf('Found %d preferences', $set->count()));
/** @var Preference $preference */
@@ -166,8 +165,8 @@ class ProfileController extends Controller
*/
public function deleteCode()
{
Preferences::delete('twoFactorAuthEnabled');
Preferences::delete('twoFactorAuthSecret');
app('preferences')->delete('twoFactorAuthEnabled');
app('preferences')->delete('twoFactorAuthSecret');
session()->flash('success', (string)trans('firefly.pref_two_factor_auth_disabled'));
session()->flash('info', (string)trans('firefly.pref_two_factor_auth_remove_it'));
@@ -186,7 +185,7 @@ class ProfileController extends Controller
if ($repository->hasRole($user, 'demo')) {
return redirect(route('profile.index'));
}
$hasTwoFactorAuthSecret = (null !== Preferences::get('twoFactorAuthSecret'));
$hasTwoFactorAuthSecret = (null !== app('preferences')->get('twoFactorAuthSecret'));
// if we don't have a valid secret yet, redirect to the code page to get one.
if (!$hasTwoFactorAuthSecret) {
@@ -196,7 +195,7 @@ class ProfileController extends Controller
// If FF3 already has a secret, just set the two factor auth enabled to 1,
// and let the user continue with the existing secret.
Preferences::set('twoFactorAuthEnabled', 1);
app('preferences')->set('twoFactorAuthEnabled', 1);
return redirect(route('profile.index'));
}
@@ -220,15 +219,15 @@ class ProfileController extends Controller
}
$subTitle = auth()->user()->email;
$userId = auth()->user()->id;
$enabled2FA = 1 === (int)Preferences::get('twoFactorAuthEnabled', 0)->data;
$enabled2FA = 1 === (int)app('preferences')->get('twoFactorAuthEnabled', 0)->data;
/** @var User $user */
$user = auth()->user();
// get access token or create one.
$accessToken = Preferences::get('access_token', null);
$accessToken = app('preferences')->get('access_token', null);
if (null === $accessToken) {
$token = $user->generateAccessToken();
$accessToken = Preferences::set('access_token', $token);
$accessToken = app('preferences')->set('access_token', $token);
}
return view('profile.index', compact('subTitle', 'userId', 'accessToken', 'enabled2FA'));
@@ -312,8 +311,8 @@ class ProfileController extends Controller
*/
public function postCode(TokenFormRequest $request)
{
Preferences::set('twoFactorAuthEnabled', 1);
Preferences::set('twoFactorAuthSecret', session()->get('two-factor-secret'));
app('preferences')->set('twoFactorAuthEnabled', 1);
app('preferences')->set('twoFactorAuthSecret', session()->get('two-factor-secret'));
session()->flash('success', (string)trans('firefly.saved_preferences'));
app('preferences')->mark();
@@ -353,7 +352,7 @@ class ProfileController extends Controller
/** @var User $user */
$user = auth()->user();
$token = $user->generateAccessToken();
Preferences::set('access_token', $token);
app('preferences')->set('access_token', $token);
session()->flash('success', (string)trans('firefly.token_regenerated'));
return redirect(route('profile.index'));
@@ -371,7 +370,7 @@ class ProfileController extends Controller
public function undoEmailChange(UserRepositoryInterface $repository, string $token, string $hash)
{
// find preference with this token value.
$set = Preferences::findByName('email_change_undo_token');
$set = app('preferences')->findByName('email_change_undo_token');
$user = null;
/** @var Preference $preference */
foreach ($set as $preference) {
@@ -385,7 +384,7 @@ class ProfileController extends Controller
// found user.
// which email address to return to?
$set = Preferences::beginsWith($user, 'previous_email_');
$set = app('preferences')->beginsWith($user, 'previous_email_');
/** @var string $match */
$match = null;
foreach ($set as $entry) {

View File

@@ -37,8 +37,6 @@ use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Collection;
use Log;
use Preferences;
use View;
/**
* Class ReportController.
@@ -62,7 +60,7 @@ class ReportController extends Controller
function ($request, $next) {
app('view')->share('title', trans('firefly.reports'));
app('view')->share('mainTitleIcon', 'fa-line-chart');
View::share('subTitleIcon', 'fa-calendar');
app('view')->share('subTitleIcon', 'fa-calendar');
$this->helper = app(ReportHelperInterface::class);
$this->repository = app(BudgetRepositoryInterface::class);
@@ -91,7 +89,7 @@ class ReportController extends Controller
}
$this->repository->cleanupBudgets();
View::share(
app('view')->share(
'subTitle', trans(
'firefly.report_account',
['start' => $start->formatLocalized($this->monthFormat), 'end' => $end->formatLocalized($this->monthFormat)]
@@ -124,7 +122,7 @@ class ReportController extends Controller
}
$this->repository->cleanupBudgets();
View::share(
app('view')->share(
'subTitle',
trans(
'firefly.report_audit',
@@ -161,7 +159,7 @@ class ReportController extends Controller
}
$this->repository->cleanupBudgets();
View::share(
app('view')->share(
'subTitle',
trans(
'firefly.report_budget',
@@ -199,7 +197,7 @@ class ReportController extends Controller
}
$this->repository->cleanupBudgets();
View::share(
app('view')->share(
'subTitle',
trans(
'firefly.report_category',
@@ -237,7 +235,7 @@ class ReportController extends Controller
}
$this->repository->cleanupBudgets();
View::share(
app('view')->share(
'subTitle',
trans(
'firefly.report_default',
@@ -264,7 +262,7 @@ class ReportController extends Controller
/** @var Carbon $start */
$start = clone session('first');
$months = $this->helper->listOfMonths($start);
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
$customFiscalYear = app('preferences')->get('customFiscalYear', 0)->data;
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$accountList = implode(',', $accounts->pluck('id')->toArray());
$this->repository->cleanupBudgets();
@@ -395,7 +393,7 @@ class ReportController extends Controller
}
$this->repository->cleanupBudgets();
View::share(
app('view')->share(
'subTitle',
trans(
'firefly.report_tag',

View File

@@ -33,7 +33,6 @@ use FireflyIII\Support\CacheProperties;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use View;
/**
* Class TagController.
@@ -49,7 +48,7 @@ class TagController extends Controller
public function __construct()
{
parent::__construct();
View::share('hideTags', true);
app('view')->share('hideTags', true);
$this->redirectUri = route('tags.index');
$this->middleware(

View File

@@ -38,7 +38,6 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Log;
use Preferences;
use View;
/**
@@ -63,7 +62,7 @@ class SingleController extends Controller
$maxFileSize = app('steam')->phpBytes(ini_get('upload_max_filesize'));
$maxPostSize = app('steam')->phpBytes(ini_get('post_max_size'));
$uploadSize = min($maxFileSize, $maxPostSize);
View::share('uploadSize', $uploadSize);
app('view')->share('uploadSize', $uploadSize);
// some useful repositories:
$this->middleware(
@@ -148,7 +147,7 @@ class SingleController extends Controller
$preFilled = session()->has('preFilled') ? session('preFilled') : [];
$subTitle = trans('form.add_new_' . $what);
$subTitleIcon = 'fa-plus';
$optionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
$optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
$source = (int)$request->get('source');
// grab old currency ID from old data:
@@ -259,7 +258,7 @@ class SingleController extends Controller
// journal related code
$sourceAccounts = $repository->getJournalSourceAccounts($journal);
$destinationAccounts = $repository->getJournalDestinationAccounts($journal);
$optionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
$optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
$pTransaction = $repository->getFirstPosTransaction($journal);
$foreignCurrency = $pTransaction->foreignCurrency ?? $pTransaction->transactionCurrency;
$preFilled = [

View File

@@ -38,7 +38,6 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Transformers\TransactionTransformer;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Preferences;
use Symfony\Component\HttpFoundation\ParameterBag;
use View;
@@ -102,7 +101,7 @@ class SplitController extends Controller
$budgets = ExpandedForm::makeSelectListWithEmpty($this->budgets->getActiveBudgets());
// other fields
$optionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
$optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
$preFilled = $this->arrayFromJournal($request, $journal);
// put previous url in session if not redirect from store (not "return_to_edit").

View File

@@ -40,7 +40,6 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Log;
use Preferences;
use Symfony\Component\HttpFoundation\ParameterBag;
use View;
@@ -85,7 +84,7 @@ class TransactionController extends Controller
$subTitleIcon = config('firefly.transactionIconsByWhat.' . $what);
$types = config('firefly.transactionTypesByWhat.' . $what);
$page = (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
if (null === $start) {
$start = session('start');
$end = session('end');
@@ -130,7 +129,7 @@ class TransactionController extends Controller
$subTitleIcon = config('firefly.transactionIconsByWhat.' . $what);
$types = config('firefly.transactionTypesByWhat.' . $what);
$page = (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$path = route('transactions.index.all', [$what]);
$first = $this->repository->firstNull();
$start = null === $first ? new Carbon : $first->date;
@@ -245,7 +244,7 @@ class TransactionController extends Controller
*/
private function getPeriodOverview(string $what, Carbon $date): Collection
{
$range = Preferences::get('viewRange', '1M')->data;
$range = app('preferences')->get('viewRange', '1M')->data;
$first = $this->repository->firstNull();
$start = new Carbon;
$start->subYear();