Trying to fix piggies [skip ci]

This commit is contained in:
James Cole
2014-08-01 07:04:36 +02:00
parent 706d853b04
commit bae750e0ab
6 changed files with 124 additions and 26 deletions

View File

@@ -42,6 +42,17 @@ Route::bind('limit', function($value, $route)
return null;
});
Route::bind('piggybank', function($value, $route)
{
if(Auth::check()) {
return Piggybank::
where('piggybanks.id', $value)->
leftJoin('accounts','accounts.id','=','piggybanks.account_id')->
where('accounts.user_id',Auth::user()->id)->first(['piggybanks.*']);
}
return null;
});
// protected routes:
Route::group(['before' => 'auth'], function () {
@@ -67,6 +78,7 @@ Route::group(['before' => 'auth'], function () {
// piggy bank controller
Route::get('/piggybanks',['uses' => 'PiggybankController@index','as' => 'piggybanks.index']);
Route::get('/piggybanks/create', ['uses' => 'PiggybankController@create','as' => 'piggybanks.create']);
Route::post('/piggybanks/updateAmount/{piggybank}',['uses' => 'PiggybankController@updateAmount','as' => 'piggybanks.updateAmount']);
// preferences controller
@@ -140,6 +152,7 @@ Route::group(['before' => 'csrf|auth'], function () {
// preferences controller
Route::post('/preferences', ['uses' => 'PreferencesController@postIndex']);