mirror of
https://github.com/brunofontes/shareit.git
synced 2024-11-24 04:14:57 +00:00
Adding Take and Return controllers
This commit is contained in:
parent
1408e558d7
commit
842976c77f
18
app/Http/Controllers/ReturnController.php
Normal file
18
app/Http/Controllers/ReturnController.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use \App\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ReturnController extends Controller
|
||||||
|
{
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$item = User::find(\Auth::id())->items()->find(request('item'));
|
||||||
|
$item->usedBy = null;
|
||||||
|
$item->save();
|
||||||
|
|
||||||
|
return redirect('home');
|
||||||
|
}
|
||||||
|
}
|
18
app/Http/Controllers/TakeController.php
Normal file
18
app/Http/Controllers/TakeController.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use \App\Item;
|
||||||
|
use \App\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class TakeController extends Controller
|
||||||
|
{
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$item = User::find(\Auth::id())->items()->find(request('item'));
|
||||||
|
$item->usedBy = \Auth::id();
|
||||||
|
$item->save();
|
||||||
|
return redirect('home');
|
||||||
|
}
|
||||||
|
}
|
@ -22,7 +22,10 @@ Route::post('/product', 'ProductController@store')->middleware('auth');
|
|||||||
Route::get('/item', 'ItemController@index')->middleware('auth');
|
Route::get('/item', 'ItemController@index')->middleware('auth');
|
||||||
Route::get('/item/{item}', 'ItemController@show')->middleware('auth');
|
Route::get('/item/{item}', 'ItemController@show')->middleware('auth');
|
||||||
Route::post('/item', 'ItemController@store')->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();
|
Auth::routes();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user