mirror of
https://github.com/brunofontes/shareit.git
synced 2024-11-23 20:10:52 +00:00
Adding Take and Return controllers
This commit is contained in:
parent
52eda15057
commit
9debf5548c
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/{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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user