mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-25 06:51:08 +00:00
Simplify controllers
This commit is contained in:
@@ -399,6 +399,10 @@ class JournalCollector implements JournalCollectorInterface
|
|||||||
*/
|
*/
|
||||||
public function setPage(int $page): JournalCollectorInterface
|
public function setPage(int $page): JournalCollectorInterface
|
||||||
{
|
{
|
||||||
|
if ($page < 1) {
|
||||||
|
$page = 1;
|
||||||
|
}
|
||||||
|
|
||||||
$this->page = $page;
|
$this->page = $page;
|
||||||
|
|
||||||
if ($page > 0) {
|
if ($page > 0) {
|
||||||
|
@@ -254,7 +254,7 @@ class AccountController extends Controller
|
|||||||
$currencyRepos = app(CurrencyRepositoryInterface::class);
|
$currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||||
$range = Preferences::get('viewRange', '1M')->data;
|
$range = Preferences::get('viewRange', '1M')->data;
|
||||||
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
|
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
|
||||||
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
|
$page = intval($request->get('page'));
|
||||||
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
||||||
$chartUri = route('chart.account.single', [$account->id]);
|
$chartUri = route('chart.account.single', [$account->id]);
|
||||||
$start = null;
|
$start = null;
|
||||||
@@ -275,22 +275,20 @@ class AccountController extends Controller
|
|||||||
if (strlen($moment) > 0 && $moment !== 'all') {
|
if (strlen($moment) > 0 && $moment !== 'all') {
|
||||||
$start = new Carbon($moment);
|
$start = new Carbon($moment);
|
||||||
$end = Navigation::endOfPeriod($start, $range);
|
$end = Navigation::endOfPeriod($start, $range);
|
||||||
$subTitle = trans(
|
$fStart = $start->formatLocalized($this->monthAndDayFormat);
|
||||||
'firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $start->formatLocalized($this->monthAndDayFormat),
|
$fEnd = $end->formatLocalized($this->monthAndDayFormat);
|
||||||
'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
$subTitle = trans('firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $fStart, 'end' => $fEnd]);
|
||||||
);
|
|
||||||
$chartUri = route('chart.account.period', [$account->id, $start->format('Y-m-d')]);
|
$chartUri = route('chart.account.period', [$account->id, $start->format('Y-m-d')]);
|
||||||
$periods = $this->getPeriodOverview($account);
|
$periods = $this->getPeriodOverview($account);
|
||||||
}
|
}
|
||||||
|
|
||||||
// prep for current period
|
// prep for current period view
|
||||||
if (strlen($moment) === 0) {
|
if (strlen($moment) === 0) {
|
||||||
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
|
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||||
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
|
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
|
||||||
$subTitle = trans(
|
$fStart = $start->formatLocalized($this->monthAndDayFormat);
|
||||||
'firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $start->formatLocalized($this->monthAndDayFormat),
|
$fEnd = $end->formatLocalized($this->monthAndDayFormat);
|
||||||
'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
$subTitle = trans('firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $fStart, 'end' => $fEnd]);
|
||||||
);
|
|
||||||
$periods = $this->getPeriodOverview($account);
|
$periods = $this->getPeriodOverview($account);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,7 +305,7 @@ class AccountController extends Controller
|
|||||||
$collector->setRange($start, $end);
|
$collector->setRange($start, $end);
|
||||||
}
|
}
|
||||||
$journals = $collector->getPaginatedJournals();
|
$journals = $collector->getPaginatedJournals();
|
||||||
$journals->setPath(route('accounts.show',[$account->id, $moment]));
|
$journals->setPath(route('accounts.show', [$account->id, $moment]));
|
||||||
$count = $journals->getCollection()->count();
|
$count = $journals->getCollection()->count();
|
||||||
if ($count === 0 && $loop < 3) {
|
if ($count === 0 && $loop < 3) {
|
||||||
$start->subDay();
|
$start->subDay();
|
||||||
@@ -318,11 +316,10 @@ class AccountController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($moment !== 'all' && $loop > 1) {
|
if ($moment !== 'all' && $loop > 1) {
|
||||||
|
$fStart = $start->formatLocalized($this->monthAndDayFormat);
|
||||||
|
$fEnd = $end->formatLocalized($this->monthAndDayFormat);
|
||||||
$chartUri = route('chart.account.period', [$account->id, $start->format('Y-m-d')]);
|
$chartUri = route('chart.account.period', [$account->id, $start->format('Y-m-d')]);
|
||||||
$subTitle = trans(
|
$subTitle = trans('firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $fStart, 'end' => $fEnd]);
|
||||||
'firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $start->formatLocalized($this->monthAndDayFormat),
|
|
||||||
'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
|
||||||
);
|
|
||||||
Session::flash('info', trans('firefly.jump_back_in_time'));
|
Session::flash('info', trans('firefly.jump_back_in_time'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -206,7 +206,7 @@ class BillController extends Controller
|
|||||||
/** @var Carbon $date */
|
/** @var Carbon $date */
|
||||||
$date = session('start');
|
$date = session('start');
|
||||||
$year = $date->year;
|
$year = $date->year;
|
||||||
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
|
$page = intval($request->get('page'));
|
||||||
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
||||||
$yearAverage = $repository->getYearAverage($bill, $date);
|
$yearAverage = $repository->getYearAverage($bill, $date);
|
||||||
$overallAverage = $repository->getOverallAverage($bill);
|
$overallAverage = $repository->getOverallAverage($bill);
|
||||||
|
@@ -294,7 +294,7 @@ class BudgetController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
|
$page = intval($request->get('page'));
|
||||||
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
||||||
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
@@ -359,7 +359,7 @@ class BudgetController extends Controller
|
|||||||
/** @var Carbon $start */
|
/** @var Carbon $start */
|
||||||
$start = session('first', Carbon::create()->startOfYear());
|
$start = session('first', Carbon::create()->startOfYear());
|
||||||
$end = new Carbon;
|
$end = new Carbon;
|
||||||
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
|
$page = intval($request->get('page'));
|
||||||
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
||||||
$limits = $this->getLimits($budget, $start, $end);
|
$limits = $this->getLimits($budget, $start, $end);
|
||||||
$repetition = null;
|
$repetition = null;
|
||||||
@@ -390,7 +390,7 @@ class BudgetController extends Controller
|
|||||||
throw new FireflyException('This budget limit is not part of this budget.');
|
throw new FireflyException('This budget limit is not part of this budget.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
|
$page = intval($request->get('page'));
|
||||||
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
||||||
$subTitle = trans(
|
$subTitle = trans(
|
||||||
'firefly.budget_in_period', [
|
'firefly.budget_in_period', [
|
||||||
|
@@ -200,7 +200,7 @@ class CategoryController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
|
$page = intval($request->get('page'));
|
||||||
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
||||||
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
@@ -249,7 +249,7 @@ class CategoryController extends Controller
|
|||||||
// default values:
|
// default values:
|
||||||
$subTitle = $category->name;
|
$subTitle = $category->name;
|
||||||
$subTitleIcon = 'fa-bar-chart';
|
$subTitleIcon = 'fa-bar-chart';
|
||||||
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
|
$page = intval($request->get('page'));
|
||||||
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$loop = 0;
|
$loop = 0;
|
||||||
|
@@ -235,7 +235,7 @@ class ImportController extends Controller
|
|||||||
// get possible warning from configurator:
|
// get possible warning from configurator:
|
||||||
$warning = $configurator->getWarningMessage();
|
$warning = $configurator->getWarningMessage();
|
||||||
|
|
||||||
if(strlen($warning) > 0) {
|
if (strlen($warning) > 0) {
|
||||||
Session::flash('warning', $warning);
|
Session::flash('warning', $warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -215,7 +215,7 @@ class TagController extends Controller
|
|||||||
// default values:
|
// default values:
|
||||||
$subTitle = $tag->tag;
|
$subTitle = $tag->tag;
|
||||||
$subTitleIcon = 'fa-tag';
|
$subTitleIcon = 'fa-tag';
|
||||||
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
|
$page = intval($request->get('page'));
|
||||||
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$loop = 0;
|
$loop = 0;
|
||||||
|
@@ -71,7 +71,7 @@ class TransactionController extends Controller
|
|||||||
// default values:
|
// default values:
|
||||||
$subTitleIcon = config('firefly.transactionIconsByWhat.' . $what);
|
$subTitleIcon = config('firefly.transactionIconsByWhat.' . $what);
|
||||||
$types = config('firefly.transactionTypesByWhat.' . $what);
|
$types = config('firefly.transactionTypesByWhat.' . $what);
|
||||||
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
|
$page = intval($request->get('page'));
|
||||||
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$loop = 0;
|
$loop = 0;
|
||||||
@@ -94,7 +94,7 @@ class TransactionController extends Controller
|
|||||||
if (strlen($moment) > 0 && $moment !== 'all') {
|
if (strlen($moment) > 0 && $moment !== 'all') {
|
||||||
$start = new Carbon($moment);
|
$start = new Carbon($moment);
|
||||||
$end = Navigation::endOfPeriod($start, $range);
|
$end = Navigation::endOfPeriod($start, $range);
|
||||||
$path = route('transactions.index', [$what, $moment]);
|
$path = route('transactions.index', [$what, $moment]);
|
||||||
$subTitle = trans(
|
$subTitle = trans(
|
||||||
'firefly.title_' . $what . '_between',
|
'firefly.title_' . $what . '_between',
|
||||||
['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
||||||
|
@@ -817,6 +817,7 @@ Breadcrumbs::register(
|
|||||||
}
|
}
|
||||||
|
|
||||||
$breadcrumbs->parent('index');
|
$breadcrumbs->parent('index');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user