diff --git a/app/controllers/BudgetController.php b/app/controllers/BudgetController.php index f3453657ed..fd246975c5 100644 --- a/app/controllers/BudgetController.php +++ b/app/controllers/BudgetController.php @@ -46,7 +46,7 @@ class BudgetController extends BaseController } krsort($reps); - return View::make('budgets.index')->with('group', $group)->with('reps',$reps); + return View::make('budgets.index')->with('group', $group)->with('reps', $reps); break; @@ -133,4 +133,5 @@ class BudgetController extends BaseController } + } \ No newline at end of file diff --git a/app/controllers/LimitController.php b/app/controllers/LimitController.php index 07d6f739c3..c50c1f9bf2 100644 --- a/app/controllers/LimitController.php +++ b/app/controllers/LimitController.php @@ -46,4 +46,30 @@ class LimitController extends BaseController } } + public function delete($limitId) + { + $limit = $this->_limits->find($limitId); + + + if ($limit) { + return View::make('limits.delete')->with('limit', $limit); + } else { + return View::make('error')->with('message', 'No such limit!'); + } + } + + public function destroy($limitId) + { + $limit = $this->_limits->find($limitId); + + + if ($limit) { + $limit->delete(); + return Redirect::route('budgets.index'); + } else { + return View::make('error')->with('message', 'No such limit!'); + } + } + + } \ No newline at end of file diff --git a/app/lib/Firefly/Storage/Limit/EloquentLimitRepository.php b/app/lib/Firefly/Storage/Limit/EloquentLimitRepository.php index 30eedc9402..141d9bc25f 100644 --- a/app/lib/Firefly/Storage/Limit/EloquentLimitRepository.php +++ b/app/lib/Firefly/Storage/Limit/EloquentLimitRepository.php @@ -15,7 +15,7 @@ class EloquentLimitRepository implements LimitRepositoryInterface public function find($limitId) { return \Limit::with('limitrepetitions')->where('limits.id', $limitId)->leftJoin('components', 'components.id', '=', 'limits.component_id') - ->where('components.user_id', \Auth::user()->id)->first(); + ->where('components.user_id', \Auth::user()->id)->first(['limits.*']); } public function store($data) diff --git a/app/routes.php b/app/routes.php index 827c4827bb..2f5103e29b 100644 --- a/app/routes.php +++ b/app/routes.php @@ -41,10 +41,7 @@ Route::group(['before' => 'auth'], function () { // transaction controller: - Route::get('/transactions/create/{what}', ['uses' => 'TransactionController@create', 'as' => 'transactions.create']) - ->where(['what' => 'withdrawal|deposit|transfer']); - - + Route::get('/transactions/create/{what}', ['uses' => 'TransactionController@create', 'as' => 'transactions.create'])->where(['what' => 'withdrawal|deposit|transfer']); Route::get('/transaction/show/{id}',['uses' => 'TransactionController@show','as' => 'transactions.show']); Route::get('/transaction/edit/{id}',['uses' => 'TransactionController@edit','as' => 'transactions.edit']); Route::get('/transaction/delete/{id}',['uses' => 'TransactionController@delete','as' => 'transactions.delete']); @@ -73,6 +70,7 @@ Route::group(['before' => 'csrf|auth'], function () { // limit controller: Route::post('/limits/store', ['uses' => 'LimitController@store', 'as' => 'budgets.limits.store']); + Route::post('/budgets/limits/destroy/{id?}',['uses' => 'LimitController@destroy','as' => 'budgets.limits.destroy']); // transaction controller: Route::post('/transactions/store/{what}', ['uses' => 'TransactionController@store', 'as' => 'transactions.store']) diff --git a/app/views/limits/delete.blade.php b/app/views/limits/delete.blade.php new file mode 100644 index 0000000000..6f5b9b4d55 --- /dev/null +++ b/app/views/limits/delete.blade.php @@ -0,0 +1,39 @@ +@extends('layouts.default') +@section('content') +
+
+

Firefly + Delete limit +

+
+
+ +{{Form::open(['class' => 'form-horizontal','url' => route('budgets.limits.destroy',$limit->id)])}} + +
+
+

+ Destroying a limit (an envelope) does not remove any transactions from the budget. +

+

+ Are you sure? +

+ +
+
+ +
+
+ +
+
+ + +{{Form::open()}} + + +@stop +@section('scripts') + + +@stop \ No newline at end of file