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();