firefly-iii/app/Http/breadcrumbs.php

404 lines
13 KiB
PHP
Raw Normal View History

2015-02-22 02:46:21 -06:00
<?php
use Carbon\Carbon;
use DaveJamesMiller\Breadcrumbs\Generator;
2015-02-22 08:40:13 -06:00
use FireflyIII\Models\Account;
2015-02-25 08:19:14 -06:00
use FireflyIII\Models\Bill;
2015-03-29 14:27:51 -05:00
use FireflyIII\Models\Budget;
2015-02-23 14:19:16 -06:00
use FireflyIII\Models\Category;
2015-02-22 08:40:13 -06:00
use FireflyIII\Models\LimitRepetition;
2015-02-24 14:10:25 -06:00
use FireflyIII\Models\PiggyBank;
2015-05-03 05:58:55 -05:00
use FireflyIII\Models\Tag;
2015-05-02 03:40:20 -05:00
use FireflyIII\Models\TransactionCurrency;
2015-03-29 14:27:51 -05:00
use FireflyIII\Models\TransactionJournal;
2015-05-03 05:58:55 -05:00
2015-02-22 02:46:21 -06:00
/*
* Back home.
*/
Breadcrumbs::register(
'home',
2015-06-06 16:09:12 -05:00
function (Generator $breadcrumbs) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->push(trans('breadcrumbs.home'), route('index'));
2015-02-22 02:46:21 -06:00
}
);
2015-05-01 11:44:49 -05:00
Breadcrumbs::register(
'index',
2015-06-06 16:09:12 -05:00
function (Generator $breadcrumbs) {
2015-05-01 11:44:49 -05:00
$breadcrumbs->push(trans('breadcrumbs.home'), route('index'));
2015-05-01 11:44:49 -05:00
}
);
//trans('breadcrumbs.')
2015-05-01 11:44:49 -05:00
2015-02-22 02:46:21 -06:00
// accounts
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'accounts.index', function (Generator $breadcrumbs, $what) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('home');
2015-06-11 11:32:31 -05:00
$breadcrumbs->push(trans('firefly.' . strtolower(e($what)) . '_accounts'), route('accounts.index', [$what]));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'accounts.create', function (Generator $breadcrumbs, $what) {
$breadcrumbs->parent('accounts.index', $what);
2015-05-26 13:37:01 -05:00
$breadcrumbs->push(trans('breadcrumbs.new_' . strtolower(e($what)) . '_account'), route('accounts.create', [$what]));
}
);
2015-02-22 02:46:21 -06:00
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'accounts.show', function (Generator $breadcrumbs, Account $account) {
2015-05-21 00:30:38 -05:00
$what = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type);
2015-05-21 00:44:44 -05:00
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('accounts.index', $what);
2015-05-26 13:37:01 -05:00
$breadcrumbs->push(e($account->name), route('accounts.show', [$account->id]));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'accounts.delete', function (Generator $breadcrumbs, Account $account) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('accounts.show', $account);
2015-06-11 11:32:31 -05:00
$breadcrumbs->push(trans('firefly.delete_account', ['name' => e($account->name)]), route('accounts.delete', [$account->id]));
2015-02-22 02:46:21 -06:00
}
);
2015-02-22 02:46:21 -06:00
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'accounts.edit', function (Generator $breadcrumbs, Account $account) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('accounts.show', $account);
2015-05-21 00:30:38 -05:00
$what = Config::get('firefly.shortNamesByFullName.' . $account->accountType->type);
2015-06-11 11:32:31 -05:00
$breadcrumbs->push(trans('firefly.edit_' . $what . '_account', ['name' => e($account->name)]), route('accounts.edit', [$account->id]));
2015-02-22 02:46:21 -06:00
}
);
// budgets.
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'budgets.index', function (Generator $breadcrumbs) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('home');
2015-06-11 11:32:31 -05:00
$breadcrumbs->push(trans('firefly.budgets'), route('budgets.index'));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'budgets.create', function (Generator $breadcrumbs) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('budgets.index');
2015-06-11 11:32:31 -05:00
$breadcrumbs->push(trans('firefly.create_new_budget'), route('budgets.create'));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'budgets.edit', function (Generator $breadcrumbs, Budget $budget) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('budgets.show', $budget);
2015-06-11 11:32:31 -05:00
$breadcrumbs->push(trans('firefly.edit_budget', ['name' => e($budget->name)]), route('budgets.edit', [$budget->id]));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'budgets.delete', function (Generator $breadcrumbs, Budget $budget) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('budgets.show', $budget);
2015-06-11 11:32:31 -05:00
$breadcrumbs->push(trans('firefly.delete_budget', ['name' => e($budget->name)]), route('budgets.delete', [$budget->id]));
2015-02-22 02:46:21 -06:00
}
);
2015-05-02 02:31:57 -05:00
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'budgets.noBudget', function (Generator $breadcrumbs, $subTitle) {
2015-05-02 02:31:57 -05:00
$breadcrumbs->parent('budgets.index');
$breadcrumbs->push($subTitle, route('budgets.noBudget'));
}
);
2015-02-22 02:46:21 -06:00
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'budgets.show', function (Generator $breadcrumbs, Budget $budget, LimitRepetition $repetition = null) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('budgets.index');
2015-05-26 13:37:01 -05:00
$breadcrumbs->push(e($budget->name), route('budgets.show', [$budget->id]));
2015-02-22 08:40:13 -06:00
if (!is_null($repetition) && !is_null($repetition->id)) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->push(
2015-05-26 13:37:01 -05:00
Navigation::periodShow($repetition->startdate, $repetition->budgetLimit->repeat_freq), route('budgets.show', [$budget->id, $repetition->id])
2015-02-22 02:46:21 -06:00
);
}
}
);
// categories
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'categories.index', function (Generator $breadcrumbs) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('home');
2015-06-11 11:32:31 -05:00
$breadcrumbs->push(trans('firefly.categories'), route('categories.index'));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'categories.create', function (Generator $breadcrumbs) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('categories.index');
$breadcrumbs->push(trans('breadcrumbs.newCategory'), route('categories.create'));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'categories.edit', function (Generator $breadcrumbs, Category $category) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('categories.show', $category);
2015-06-11 11:32:31 -05:00
$breadcrumbs->push(trans('firefly.edit_category', ['name' => e($category->name)]), route('categories.edit', [$category->id]));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'categories.delete', function (Generator $breadcrumbs, Category $category) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('categories.show', $category);
2015-06-11 11:32:31 -05:00
$breadcrumbs->push(trans('firefly.delete_category', ['name' => e($category->name)]), route('categories.delete', [$category->id]));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'categories.show', function (Generator $breadcrumbs, Category $category) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('categories.index');
2015-05-26 13:37:01 -05:00
$breadcrumbs->push(e($category->name), route('categories.show', [$category->id]));
2015-02-22 02:46:21 -06:00
}
);
2015-05-02 02:31:57 -05:00
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'categories.noCategory', function (Generator $breadcrumbs, $subTitle) {
2015-05-02 02:31:57 -05:00
$breadcrumbs->parent('categories.index');
$breadcrumbs->push($subTitle, route('categories.noCategory'));
}
);
2015-05-02 03:40:20 -05:00
// currencies.
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'currency.index', function (Generator $breadcrumbs) {
2015-05-02 03:40:20 -05:00
$breadcrumbs->parent('home');
2015-06-11 11:32:31 -05:00
$breadcrumbs->push(trans('firefly.currencies'), route('currency.index'));
2015-05-02 03:40:20 -05:00
}
);
2015-06-21 08:09:10 -05:00
Breadcrumbs::register(
'currency.create', function (Generator $breadcrumbs) {
$breadcrumbs->parent('currency.index');
$breadcrumbs->push(trans('firefly.create_currency'), route('currency.create'));
}
);
2015-05-02 03:40:20 -05:00
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'currency.edit', function (Generator $breadcrumbs, TransactionCurrency $currency) {
2015-05-02 03:40:20 -05:00
$breadcrumbs->parent('currency.index');
2015-05-26 13:37:01 -05:00
$breadcrumbs->push(trans('breadcrumbs.edit_currency', ['name' => e($currency->name)]), route('currency.edit', [$currency->id]));
2015-05-02 03:40:20 -05:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'currency.delete', function (Generator $breadcrumbs, TransactionCurrency $currency) {
2015-05-02 03:40:20 -05:00
$breadcrumbs->parent('currency.index');
2015-05-26 13:37:01 -05:00
$breadcrumbs->push(trans('breadcrumbs.delete_currency', ['name' => e($currency->name)]), route('currency.delete', [$currency->id]));
2015-05-02 03:40:20 -05:00
}
);
2015-02-22 02:46:21 -06:00
// piggy banks
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'piggy-banks.index', function (Generator $breadcrumbs) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.piggyBanks'), route('piggy-banks.index'));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'piggy-banks.create', function (Generator $breadcrumbs) {
2015-02-24 14:10:25 -06:00
$breadcrumbs->parent('piggy-banks.index');
$breadcrumbs->push(trans('breadcrumbs.newPiggyBank'), route('piggy-banks.create'));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'piggy-banks.edit', function (Generator $breadcrumbs, PiggyBank $piggyBank) {
2015-02-24 14:10:25 -06:00
$breadcrumbs->parent('piggy-banks.show', $piggyBank);
2015-05-26 13:37:01 -05:00
$breadcrumbs->push(trans('breadcrumbs.edit_piggyBank', ['name' => e($piggyBank->name)]), route('piggy-banks.edit', [$piggyBank->id]));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'piggy-banks.delete', function (Generator $breadcrumbs, PiggyBank $piggyBank) {
2015-02-24 14:10:25 -06:00
$breadcrumbs->parent('piggy-banks.show', $piggyBank);
2015-05-26 13:37:01 -05:00
$breadcrumbs->push(trans('breadcrumbs.delete_piggyBank', ['name' => e($piggyBank->name)]), route('piggy-banks.delete', [$piggyBank->id]));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'piggy-banks.show', function (Generator $breadcrumbs, PiggyBank $piggyBank) {
2015-02-24 14:10:25 -06:00
$breadcrumbs->parent('piggy-banks.index');
2015-05-26 13:37:01 -05:00
$breadcrumbs->push(e($piggyBank->name), route('piggy-banks.show', [$piggyBank->id]));
2015-02-22 02:46:21 -06:00
}
);
// preferences
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'preferences', function (Generator $breadcrumbs) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.preferences'), route('preferences'));
2015-02-22 02:46:21 -06:00
}
);
// profile
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'profile', function (Generator $breadcrumbs) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.profile'), route('profile'));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'change-password', function (Generator $breadcrumbs) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('profile');
$breadcrumbs->push(trans('breadcrumbs.changePassword'), route('change-password'));
2015-02-22 02:46:21 -06:00
}
);
// bills
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'bills.index', function (Generator $breadcrumbs) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.bills'), route('bills.index'));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'bills.create', function (Generator $breadcrumbs) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('bills.index');
$breadcrumbs->push(trans('breadcrumbs.newBill'), route('bills.create'));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'bills.edit', function (Generator $breadcrumbs, Bill $bill) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('bills.show', $bill);
2015-05-26 13:37:01 -05:00
$breadcrumbs->push(trans('breadcrumbs.edit_bill', ['name' => e($bill->name)]), route('bills.edit', [$bill->id]));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'bills.delete', function (Generator $breadcrumbs, Bill $bill) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('bills.show', $bill);
2015-05-26 13:37:01 -05:00
$breadcrumbs->push(trans('breadcrumbs.delete_bill', ['name' => e($bill->name)]), route('bills.delete', [$bill->id]));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'bills.show', function (Generator $breadcrumbs, Bill $bill) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('bills.index');
2015-05-26 13:37:01 -05:00
$breadcrumbs->push(e($bill->name), route('bills.show', [$bill->id]));
2015-02-22 02:46:21 -06:00
}
);
// reports
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'reports.index', function (Generator $breadcrumbs) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.reports'), route('reports.index'));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'reports.year', function (Generator $breadcrumbs, Carbon $date, $shared) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('reports.index');
2015-05-15 14:01:24 -05:00
if ($shared) {
$title = trans('breadcrumbs.yearly_report_shared', ['date' => $date->year]);
} else {
$title = trans('breadcrumbs.yearly_report', ['date' => $date->year]);
}
2015-05-26 13:37:01 -05:00
$breadcrumbs->push($title, route('reports.year', [$date->year]));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'reports.month', function (Generator $breadcrumbs, Carbon $date, $shared) {
2015-05-15 14:01:24 -05:00
$breadcrumbs->parent('reports.year', $date, $shared);
2015-06-21 03:50:45 -05:00
$language = Preferences::get('language', 'en')->data;
$format = Config::get('firefly.month.' . $language);
2015-02-22 02:46:21 -06:00
2015-05-15 14:01:24 -05:00
if ($shared) {
2015-06-21 03:50:45 -05:00
$title = trans('breadcrumbs.monthly_report_shared', ['date' => $date->formatLocalized($format)]);
2015-05-15 14:01:24 -05:00
} else {
2015-06-21 03:50:45 -05:00
$title = trans('breadcrumbs.monthly_report', ['date' => $date->formatLocalized($format)]);
2015-05-15 14:01:24 -05:00
}
$breadcrumbs->push($title, route('reports.month', [$date->year, $date->month]));
2015-02-22 02:46:21 -06:00
}
);
// search
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'search', function (Generator $breadcrumbs, $query) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('home');
2015-05-15 14:01:24 -05:00
$breadcrumbs->push(trans('breadcrumbs.searchResult', ['query' => e($query)]), route('search'));
2015-02-22 02:46:21 -06:00
}
);
// transactions
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'transactions.index', function (Generator $breadcrumbs, $what) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('home');
2015-05-26 13:37:01 -05:00
$breadcrumbs->push(trans('breadcrumbs.' . $what . '_list'), route('transactions.index', [$what]));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'transactions.create', function (Generator $breadcrumbs, $what) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('transactions.index', $what);
2015-05-26 13:37:01 -05:00
$breadcrumbs->push(trans('breadcrumbs.create_' . e($what)), route('transactions.create', [$what]));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'transactions.edit', function (Generator $breadcrumbs, TransactionJournal $journal) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('transactions.show', $journal);
2015-05-26 13:37:01 -05:00
$breadcrumbs->push(trans('breadcrumbs.edit_journal', ['description' => $journal->description]), route('transactions.edit', [$journal->id]));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'transactions.delete', function (Generator $breadcrumbs, TransactionJournal $journal) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('transactions.show', $journal);
2015-05-26 13:37:01 -05:00
$breadcrumbs->push(trans('breadcrumbs.delete_journal', ['description' => e($journal->description)]), route('transactions.delete', [$journal->id]));
2015-02-22 02:46:21 -06:00
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'transactions.show', function (Generator $breadcrumbs, TransactionJournal $journal) {
2015-02-22 02:46:21 -06:00
$breadcrumbs->parent('transactions.index', strtolower($journal->transactionType->type));
2015-05-26 13:37:01 -05:00
$breadcrumbs->push($journal->description, route('transactions.show', [$journal->id]));
2015-02-22 02:46:21 -06:00
}
);
// tags
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'tags.index', function (Generator $breadcrumbs) {
$breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.tags'), route('tags.index'));
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'tags.create', function (Generator $breadcrumbs) {
$breadcrumbs->parent('tags.index');
$breadcrumbs->push(trans('breadcrumbs.createTag'), route('tags.create'));
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'tags.edit', function (Generator $breadcrumbs, Tag $tag) {
$breadcrumbs->parent('tags.show', $tag);
2015-05-26 13:37:01 -05:00
$breadcrumbs->push(trans('breadcrumbs.edit_tag', ['tag' => e($tag->tag)]), route('tags.edit', [$tag->id]));
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'tags.delete', function (Generator $breadcrumbs, Tag $tag) {
$breadcrumbs->parent('tags.show', $tag);
2015-05-26 13:37:01 -05:00
$breadcrumbs->push(trans('breadcrumbs.delete_tag', ['tag' => e($tag->tag)]), route('tags.delete', [$tag->id]));
}
);
Breadcrumbs::register(
2015-06-06 16:09:12 -05:00
'tags.show', function (Generator $breadcrumbs, Tag $tag) {
$breadcrumbs->parent('tags.index');
2015-05-26 13:37:01 -05:00
$breadcrumbs->push(e($tag->tag), route('tags.show', [$tag->id]));
}
);