From 9debf5548cdd81dd13d36c49934b1f28d35931af Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Wed, 12 Sep 2018 21:27:35 -0300 Subject: [PATCH] Adding Take and Return controllers --- app/Http/Controllers/ReturnController.php | 18 ++++++++++++++++++ app/Http/Controllers/TakeController.php | 18 ++++++++++++++++++ routes/web.php | 5 ++++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/ReturnController.php create mode 100644 app/Http/Controllers/TakeController.php diff --git a/app/Http/Controllers/ReturnController.php b/app/Http/Controllers/ReturnController.php new file mode 100644 index 0000000..4643f24 --- /dev/null +++ b/app/Http/Controllers/ReturnController.php @@ -0,0 +1,18 @@ +items()->find(request('item')); + $item->usedBy = null; + $item->save(); + + return redirect('home'); + } +} diff --git a/app/Http/Controllers/TakeController.php b/app/Http/Controllers/TakeController.php new file mode 100644 index 0000000..bf84b53 --- /dev/null +++ b/app/Http/Controllers/TakeController.php @@ -0,0 +1,18 @@ +items()->find(request('item')); + $item->usedBy = \Auth::id(); + $item->save(); + return redirect('home'); + } +} diff --git a/routes/web.php b/routes/web.php index daa1840..d4289eb 100644 --- a/routes/web.php +++ b/routes/web.php @@ -22,7 +22,10 @@ Route::post('/product', 'ProductController@store')->middleware('auth'); Route::get('/item', 'ItemController@index')->middleware('auth'); Route::get('/item/{item}', 'ItemController@show')->middleware('auth'); Route::post('/item', 'ItemController@store')->middleware('auth'); -Route::delete('/item/{item}', 'ItemController@delete')->middleware('auth'); +Route::delete('/item', 'ItemController@delete')->middleware('auth'); + +Route::post('/take', 'TakeController@store')->middleware('auth'); +Route::post('/return', 'ReturnController@store')->middleware('auth'); Auth::routes();