Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix various routes.
James Cole098cc88d5f0d
diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.phpindex 19ccf48434..f5948f4785 100644--- a/app/Http/Controllers/CurrencyController.php+++ b/app/Http/Controllers/CurrencyController.php@@ -60,14 +60,14 @@ class CurrencyController extends Controller$subTitle = trans('firefly.create_currency');// put previous url in session if not redirect from store (not "create another").- if (session('currency.create.fromStore') !== true) {- Session::put('currency.create.url', URL::previous());+ if (session('currencies.create.fromStore') !== true) {+ Session::put('currencies.create.url', URL::previous());}- Session::forget('currency.create.fromStore');+ Session::forget('currencies.create.fromStore');Session::flash('gaEventCategory', 'currency');Session::flash('gaEventAction', 'create');- return view('currency.create', compact('subTitleIcon', 'subTitle'));+ return view('currencies.create', compact('subTitleIcon', 'subTitle'));}/**@@ -85,7 +85,7 @@ class CurrencyController extends ControllerCache::forget('FFCURRENCYSYMBOL');Cache::forget('FFCURRENCYCODE');- return redirect(route('currency.index'));+ return redirect(route('currencies.index'));}@@ -99,18 +99,18 @@ class CurrencyController extends Controllerif (!$this->canDeleteCurrency($currency)) {Session::flash('error', trans('firefly.cannot_delete_currency', ['name' => $currency->name]));- return redirect(route('currency.index'));+ return redirect(route('currencies.index'));}// put previous url in session- Session::put('currency.delete.url', URL::previous());+ Session::put('currencies.delete.url', URL::previous());Session::flash('gaEventCategory', 'currency');Session::flash('gaEventAction', 'delete');$subTitle = trans('form.delete_currency', ['name' => $currency->name]);- return view('currency.delete', compact('currency', 'subTitle'));+ return view('currencies.delete', compact('currency', 'subTitle'));}/**@@ -124,7 +124,7 @@ class CurrencyController extends Controllerif (!$this->canDeleteCurrency($currency)) {Session::flash('error', trans('firefly.cannot_delete_currency', ['name' => $currency->name]));- return redirect(route('currency.index'));+ return redirect(route('currencies.index'));}Session::flash('success', trans('firefly.deleted_currency', ['name' => $currency->name]));@@ -132,7 +132,7 @@ class CurrencyController extends Controller$currency->forceDelete();}- return redirect(session('currency.delete.url'));+ return redirect(session('currencies.delete.url'));}/**@@ -147,14 +147,14 @@ class CurrencyController extends Controller$currency->symbol = htmlentities($currency->symbol);// put previous url in session if not redirect from store (not "return_to_edit").- if (session('currency.edit.fromUpdate') !== true) {- Session::put('currency.edit.url', URL::previous());+ if (session('currencies.edit.fromUpdate') !== true) {+ Session::put('currencies.edit.url', URL::previous());}- Session::forget('currency.edit.fromUpdate');+ Session::forget('currencies.edit.fromUpdate');Session::flash('gaEventCategory', 'currency');Session::flash('gaEventAction', 'edit');- return view('currency.edit', compact('currency', 'subTitle', 'subTitleIcon'));+ return view('currencies.edit', compact('currency', 'subTitle', 'subTitleIcon'));}@@ -174,7 +174,7 @@ class CurrencyController extends Controller}- return view('currency.index', compact('currencies', 'defaultCurrency'));+ return view('currencies.index', compact('currencies', 'defaultCurrency'));}/**@@ -189,7 +189,7 @@ class CurrencyController extends Controllerif (!auth()->user()->hasRole('owner')) {Log::error('User ' . auth()->user()->id . ' is not admin, but tried to store a currency.');- return redirect(session('currency.create.url'));+ return redirect(session('currencies.create.url'));}$data = $request->getCurrencyData();@@ -197,13 +197,13 @@ class CurrencyController extends ControllerSession::flash('success', trans('firefly.created_currency', ['name' => $currency->name]));if (intval(Input::get('create_another')) === 1) {- Session::put('currency.create.fromStore', true);+ Session::put('currencies.create.fromStore', true);- return redirect(route('currency.create'))->withInput();+ return redirect(route('currencies.create'))->withInput();}// redirect to previous URL.- return redirect(session('currency.create.url'));+ return redirect(session('currencies.create.url'));}@@ -226,13 +226,13 @@ class CurrencyController extends Controllerif (intval(Input::get('return_to_edit')) === 1) {- Session::put('currency.edit.fromUpdate', true);+ Session::put('currencies.edit.fromUpdate', true);- return redirect(route('currency.edit', [$currency->id]));+ return redirect(route('currencies.edit', [$currency->id]));}// redirect to previous URL.- return redirect(session('currency.edit.url'));+ return redirect(session('currencies.edit.url'));}diff --git a/app/Http/Controllers/Transaction/SplitController.php b/app/Http/Controllers/Transaction/SplitController.phpindex a7883f2a4a..38c40f3f40 100644--- a/app/Http/Controllers/Transaction/SplitController.php+++ b/app/Http/Controllers/Transaction/SplitController.php@@ -135,20 +135,7 @@ class SplitController extends Controllerreturn $this->redirectToAccount($journal);}- $data = $this->arrayFromInput($request);-- // need to do some validation!- // sum of amount must be > 0- $sum = '0';- foreach ($data['transactions'] as $transaction) {- Session::flash('error',strval(trans('validation.amount_zero')));- $sum = bcadd($sum, strval($transaction['amount']));- }- if (bccomp($sum, '0') === 0) {- return redirect(route('transactions.edit-split', [$journal->id]))->withInput();- }--+ $data = $this->arrayFromInput($request);$journal = $repository->updateSplitJournal($journal, $data);// save attachments:diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.phpindex 925c0cac99..879fb077e7 100644--- a/app/Http/breadcrumbs.php+++ b/app/Http/breadcrumbs.php@@ -327,29 +327,29 @@ Breadcrumbs::register(* CURRENCIES*/Breadcrumbs::register(- 'currency.index', function (BreadCrumbGenerator $breadcrumbs) {+ 'currencies.index', function (BreadCrumbGenerator $breadcrumbs) {$breadcrumbs->parent('home');- $breadcrumbs->push(trans('firefly.currencies'), route('currency.index'));+ $breadcrumbs->push(trans('firefly.currencies'), route('currencies.index'));});Breadcrumbs::register(- 'currency.create', function (BreadCrumbGenerator $breadcrumbs) {- $breadcrumbs->parent('currency.index');- $breadcrumbs->push(trans('firefly.create_currency'), route('currency.create'));+ 'currencies.create', function (BreadCrumbGenerator $breadcrumbs) {+ $breadcrumbs->parent('currencies.index');+ $breadcrumbs->push(trans('firefly.create_currency'), route('currencies.create'));});Breadcrumbs::register(- 'currency.edit', function (BreadCrumbGenerator $breadcrumbs, TransactionCurrency $currency) {- $breadcrumbs->parent('currency.index');- $breadcrumbs->push(trans('breadcrumbs.edit_currency', ['name' => e($currency->name)]), route('currency.edit', [$currency->id]));+ 'currencies.edit', function (BreadCrumbGenerator $breadcrumbs, TransactionCurrency $currency) {+ $breadcrumbs->parent('currencies.index');+ $breadcrumbs->push(trans('breadcrumbs.edit_currency', ['name' => e($currency->name)]), route('currencies.edit', [$currency->id]));});Breadcrumbs::register(- 'currency.delete', function (BreadCrumbGenerator $breadcrumbs, TransactionCurrency $currency) {- $breadcrumbs->parent('currency.index');- $breadcrumbs->push(trans('breadcrumbs.delete_currency', ['name' => e($currency->name)]), route('currency.delete', [$currency->id]));+ 'currencies.delete', function (BreadCrumbGenerator $breadcrumbs, TransactionCurrency $currency) {+ $breadcrumbs->parent('currencies.index');+ $breadcrumbs->push(trans('breadcrumbs.delete_currency', ['name' => e($currency->name)]), route('currencies.delete', [$currency->id]));});diff --git a/resources/views/currency/create.twig b/resources/views/currencies/create.twigsimilarity index 92%rename from resources/views/currency/create.twigrename to resources/views/currencies/create.twigindex 26dec5a0b1..8192a47171 100644--- a/resources/views/currency/create.twig+++ b/resources/views/currencies/create.twig@@ -5,7 +5,7 @@{% endblock %}{% block content %}- <form method="POST" action="{{ route('currency.store') }}" accept-charset="UTF-8" class="form-horizontal" id="store">+ <form method="POST" action="{{ route('currencies.store') }}" accept-charset="UTF-8" class="form-horizontal" id="store"><input name="_token" type="hidden" value="{{ csrf_token() }}"><div class="row"><div class="col-lg-6 col-md-6 col-sm-12">diff --git a/resources/views/currency/delete.twig b/resources/views/currencies/delete.twigsimilarity index 90%rename from resources/views/currency/delete.twigrename to resources/views/currencies/delete.twigindex 5874f126f2..e14902a17f 100644--- a/resources/views/currency/delete.twig+++ b/resources/views/currencies/delete.twig@@ -6,7 +6,7 @@{% block content %}- <form method="POST" action="{{ route('currency.destroy',currency.id) }}" accept-charset="UTF-8" class="form-horizontal" id="destroy">+ <form method="POST" action="{{ route('currencies.destroy',currency.id) }}" accept-charset="UTF-8" class="form-horizontal" id="destroy"><input name="_token" type="hidden" value="{{ csrf_token() }}"><div class="row"><div class="col-lg-6 col-lg-offset-3 col-md-12 col-sm-12">diff --git a/resources/views/currency/edit.twig b/resources/views/currencies/edit.twigsimilarity index 96%rename from resources/views/currency/edit.twigrename to resources/views/currencies/edit.twigindex e54d5f5ca1..2c4819545e 100644--- a/resources/views/currency/edit.twig+++ b/resources/views/currencies/edit.twig@@ -5,7 +5,7 @@{% endblock %}{% block content %}- {{ Form.model(currency, {'class' : 'form-horizontal','id' : 'update','url' : route('currency.update',currency.id)}) }}+ {{ Form.model(currency, {'class' : 'form-horizontal','id' : 'update','url' : route('currencies.update',currency.id)}) }}<input type="hidden" name="id" value="{{ currency.id }}"/><div class="row">diff --git a/resources/views/currency/index.twig b/resources/views/currencies/index.twigsimilarity index 88%rename from resources/views/currency/index.twigrename to resources/views/currencies/index.twigindex 7720779d98..5955d6edc6 100644--- a/resources/views/currency/index.twig+++ b/resources/views/currencies/index.twig@@ -28,8 +28,8 @@<tr><td><div class="btn-group btn-group-xs">- <a class="btn btn-default" href="{{ route('currency.edit',currency.id) }}"><i class="fa fa-fw fa-pencil"></i></a>- <a class="btn btn-danger" href="{{ route('currency.delete',currency.id) }}"><i class="fa fa-fw fa-trash"></i></a>+ <a class="btn btn-default" href="{{ route('currencies.edit',currency.id) }}"><i class="fa fa-fw fa-pencil"></i></a>+ <a class="btn btn-danger" href="{{ route('currencies.delete',currency.id) }}"><i class="fa fa-fw fa-trash"></i></a></div></td><td>{{ currency.name }} ({{ currency.code }}) ({{ currency.symbol|raw }})</td>@@ -38,7 +38,7 @@<span class="label label-success">{{ 'default_currency'|_ }}</span>{% else %}<a class="btn btn-info btn-xs"- href="{{ route('currency.default',currency.id) }}">{{ 'make_default_currency'|_ }}</a>+ href="{{ route('currencies.default',currency.id) }}">{{ 'make_default_currency'|_ }}</a>{% endif %}</td></tr>@@ -48,7 +48,7 @@{% endif %}</div><div class="box-footer">- <a class="btn btn-success pull-right" href="{{ route('currency.create') }}">{{ 'create_currency'|_ }}</a>+ <a class="btn btn-success pull-right" href="{{ route('currencies.create') }}">{{ 'create_currency'|_ }}</a></div></div></div>diff --git a/resources/views/partials/menu-sidebar.twig b/resources/views/partials/menu-sidebar.twigindex f1b45e4a37..ead49f1f16 100644--- a/resources/views/partials/menu-sidebar.twig+++ b/resources/views/partials/menu-sidebar.twig@@ -146,7 +146,7 @@<a class="{{ activeRouteStrict('preferences') }}" href="{{ route('preferences') }}"><i class="fa fa-gear fa-fw"></i> {{ 'preferences'|_ }}</a></li><li class="{{ activeRoutePartial('currency') }}">- <a class="{{ activeRoutePartial('currency') }}" href="{{ route('currency.index') }}"><i class="fa fa-usd fa-fw"></i> {{ 'currencies'|_ }}</a>+ <a class="{{ activeRoutePartial('currency') }}" href="{{ route('currencies.index') }}"><i class="fa fa-usd fa-fw"></i> {{ 'currencies'|_ }}</a></li><!-- admin (if user admin) -->{% if Auth.user.hasRole('owner') %}diff --git a/routes/web.php b/routes/web.phpindex f0e4508d35..2185355826 100755--- a/routes/web.php+++ b/routes/web.php@@ -159,50 +159,68 @@ Route::group(Route::get('show/{budget}/{limitrepetition}', ['uses' => 'BudgetController@showWithRepetition', 'as' => 'showWithRepetition']);Route::get('list/noBudget', ['uses' => 'BudgetController@noBudget', 'as' => 'noBudget']);- Route::post('income', ['uses' => 'BudgetController@postUpdateIncome', 'as' => 'postIncome']);+ Route::post('income', ['uses' => 'BudgetController@postUpdateIncome', 'as' => 'postIncome']); // consistentRoute::post('store', ['uses' => 'BudgetController@store', 'as' => 'store']);Route::post('update/{budget}', ['uses' => 'BudgetController@update', 'as' => 'update']);Route::post('destroy/{budget}', ['uses' => 'BudgetController@destroy', 'as' => 'destroy']);Route::post('amount/{budget}', ['uses' => 'BudgetController@amount']);});+/**+ * Category Controller+ */Route::group(- ['middleware' => ['user-full-auth']], function () {+ ['middleware' => 'user-full-auth', 'prefix' => 'categories','as' => 'categories.'], function () {- /**- * Category Controller- */- Route::get('/categories', ['uses' => 'CategoryController@index', 'as' => 'categories.index']);- Route::get('/categories/create', ['uses' => 'CategoryController@create', 'as' => 'categories.create']);- Route::get('/categories/edit/{category}', ['uses' => 'CategoryController@edit', 'as' => 'categories.edit']);- Route::get('/categories/delete/{category}', ['uses' => 'CategoryController@delete', 'as' => 'categories.delete']);- Route::get('/categories/show/{category}', ['uses' => 'CategoryController@show', 'as' => 'categories.show']);- Route::get('/categories/show/{category}/{date}', ['uses' => 'CategoryController@showWithDate', 'as' => 'categories.show.date']);- Route::get('/categories/list/noCategory', ['uses' => 'CategoryController@noCategory', 'as' => 'categories.noCategory']);- Route::post('/categories/store', ['uses' => 'CategoryController@store', 'as' => 'categories.store']);- Route::post('/categories/update/{category}', ['uses' => 'CategoryController@update', 'as' => 'categories.update']);- Route::post('/categories/destroy/{category}', ['uses' => 'CategoryController@destroy', 'as' => 'categories.destroy']);+ Route::get('', ['uses' => 'CategoryController@index', 'as' => 'index']);+ Route::get('create', ['uses' => 'CategoryController@create', 'as' => 'create']);+ Route::get('edit/{category}', ['uses' => 'CategoryController@edit', 'as' => 'edit']);+ Route::get('delete/{category}', ['uses' => 'CategoryController@delete', 'as' => 'delete']);- /**- * Currency Controller- */- Route::get('/currency', ['uses' => 'CurrencyController@index', 'as' => 'currency.index']);- Route::get('/currency/create', ['uses' => 'CurrencyController@create', 'as' => 'currency.create']);- Route::get('/currency/edit/{currency}', ['uses' => 'CurrencyController@edit', 'as' => 'currency.edit']);- Route::get('/currency/delete/{currency}', ['uses' => 'CurrencyController@delete', 'as' => 'currency.delete']);- Route::get('/currency/default/{currency}', ['uses' => 'CurrencyController@defaultCurrency', 'as' => 'currency.default']);- Route::post('/currency/store', ['uses' => 'CurrencyController@store', 'as' => 'currency.store']);- Route::post('/currency/update/{currency}', ['uses' => 'CurrencyController@update', 'as' => 'currency.update']);- Route::post('/currency/destroy/{currency}', ['uses' => 'CurrencyController@destroy', 'as' => 'currency.destroy']);+ Route::get('show/{category}', ['uses' => 'CategoryController@show', 'as' => 'show']); // consistent+ Route::get('show/{category}/{date}', ['uses' => 'CategoryController@showWithDate', 'as' => 'show.date']);+ Route::get('list/noCategory', ['uses' => 'CategoryController@noCategory', 'as' => 'noCategory']);- /**- * Export Controller- */- Route::get('/export', ['uses' => 'ExportController@index', 'as' => 'export.index']);- Route::post('/export/submit', ['uses' => 'ExportController@postIndex', 'as' => 'export.export']);- Route::get('/export/status/{jobKey}', ['uses' => 'ExportController@getStatus', 'as' => 'export.status']);- Route::get('/export/download/{jobKey}', ['uses' => 'ExportController@download', 'as' => 'export.download']);+ Route::post('store', ['uses' => 'CategoryController@store', 'as' => 'store']);+ Route::post('update/{category}', ['uses' => 'CategoryController@update', 'as' => 'update']);+ Route::post('destroy/{category}', ['uses' => 'CategoryController@destroy', 'as' => 'destroy']);+});+++/**+ * Currency Controller+ */+Route::group(+ ['middleware' => 'user-full-auth', 'prefix' => 'currencies','as' => 'currencies.'], function () {+ Route::get('', ['uses' => 'CurrencyController@index', 'as' => 'index']);+ Route::get('create', ['uses' => 'CurrencyController@create', 'as' => 'create']);+ Route::get('edit/{currency}', ['uses' => 'CurrencyController@edit', 'as' => 'edit']);+ Route::get('delete/{currency}', ['uses' => 'CurrencyController@delete', 'as' => 'delete']);+ Route::get('default/{currency}', ['uses' => 'CurrencyController@defaultCurrency', 'as' => 'default']);++ Route::post('store', ['uses' => 'CurrencyController@store', 'as' => 'store']);+ Route::post('update/{currency}', ['uses' => 'CurrencyController@update', 'as' => 'update']);+ Route::post('destroy/{currency}', ['uses' => 'CurrencyController@destroy', 'as' => 'destroy']);++});++/**+ * Export Controller+ */+Route::group(+ ['middleware' => 'user-full-auth', 'prefix' => 'export','as' => 'export.'], function () {++ Route::get('', ['uses' => 'ExportController@index', 'as' => 'index']);+ Route::get('status/{jobKey}', ['uses' => 'ExportController@getStatus', 'as' => 'status']);+ Route::get('download/{jobKey}', ['uses' => 'ExportController@download', 'as' => 'download']);++ Route::post('submit', ['uses' => 'ExportController@postIndex', 'as' => 'export']);++});++Route::group(+ ['middleware' => ['user-full-auth']], function () {/*** ALL CHART Controllers