More bread crumbs.

This commit is contained in:
James Cole 2014-11-28 15:46:44 +01:00
parent 0df6c3a8dc
commit 6bb54bfa85
5 changed files with 69 additions and 3 deletions

View File

@ -1,5 +1,6 @@
<?php
use DaveJamesMiller\Breadcrumbs\Generator;
use FireflyIII\Exception\FireflyException;
/*
* Back home.
@ -12,6 +13,7 @@ Breadcrumbs::register(
}
);
// accounts
Breadcrumbs::register(
'accounts.index', function (Generator $breadcrumbs, $what) {
$breadcrumbs->parent('home');
@ -19,8 +21,69 @@ Breadcrumbs::register(
}
);
Breadcrumbs::register(
'accounts.show', function (Generator $breadcrumbs, $what, \Account $account) {
$breadcrumbs->parent('accounts.index',$what);
'accounts.show', function (Generator $breadcrumbs, \Account $account) {
switch ($account->accountType->type) {
default:
throw new FireflyException('Cannot handle account type "' . e($account->accountType->type) . '"');
break;
case 'Default account':
case 'Asset account':
$what = 'asset';
break;
case 'Expense account':
case 'Beneficiary account':
$what = 'expense';
break;
case 'Revenue account':
$what = 'revenue';
break;
}
$breadcrumbs->parent('accounts.index', $what);
$breadcrumbs->push($account->name, route('accounts.show', $account->id));
}
);
Breadcrumbs::register(
'accounts.delete', function (Generator $breadcrumbs, \Account $account) {
switch ($account->accountType->type) {
default:
throw new FireflyException('Cannot handle account type "' . e($account->accountType->type) . '"');
break;
case 'Default account':
case 'Asset account':
$what = 'asset';
break;
case 'Expense account':
case 'Beneficiary account':
$what = 'expense';
break;
case 'Revenue account':
$what = 'revenue';
break;
}
$breadcrumbs->parent('accounts.show', $account);
$breadcrumbs->push('Delete ' . $account->name, route('accounts.delete', $account->id));
}
);
Breadcrumbs::register(
'accounts.edit', function (Generator $breadcrumbs, \Account $account) {
switch ($account->accountType->type) {
default:
throw new FireflyException('Cannot handle account type "' . e($account->accountType->type) . '"');
break;
case 'Default account':
case 'Asset account':
$what = 'asset';
break;
case 'Expense account':
case 'Beneficiary account':
$what = 'expense';
break;
case 'Revenue account':
$what = 'revenue';
break;
}
$breadcrumbs->parent('accounts.show', $account);
$breadcrumbs->push('Edit ' . $account->name, route('accounts.edit', $account->id));
}
);

View File

@ -1,5 +1,6 @@
@extends('layouts.default')
@section('content')
{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $what) }}
{{Form::open(['class' => 'form-horizontal','route' => 'accounts.store'])}}
{{Form::hidden('what',$what)}}
<div class="row">

View File

@ -1,5 +1,6 @@
@extends('layouts.default')
@section('content')
{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $account) }}
{{Form::open(['class' => 'form-horizontal','url' => route('accounts.destroy',$account->id)])}}
<div class="row">
<div class="col-lg-6 col-md-12 col-sm-12">

View File

@ -1,5 +1,6 @@
@extends('layouts.default')
@section('content')
{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $account) }}
{{Form::model($account, ['class' => 'form-horizontal','url' => route('accounts.update',$account->id)])}}
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12">

View File

@ -1,6 +1,6 @@
@extends('layouts.default')
@section('content')
{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $what, $account) }}
{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $account) }}
<div class="row">
<div class="col-lg-8 col-md-6 col-sm-12">
<div class="panel panel-default">