mirror of
https://github.com/brunofontes/shareit.git
synced 2025-11-15 07:50:54 -03:00
Including item and product form validation
This commit is contained in:
@@ -7,17 +7,33 @@ use \App\Item;
|
||||
|
||||
class ItemController extends Controller
|
||||
{
|
||||
//
|
||||
public function index()
|
||||
{
|
||||
//$item = Item::all();
|
||||
//return $item; //Show a JSON file instead of the view
|
||||
return view('item');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
//TODO: Fazer innerjoint com tabela de users por item
|
||||
$item = Item::where([['id', $id], ['userID', \Auth::id()]]);
|
||||
return view('item', compact('item'));
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
//TODO: Fazer innerjoint com tabela de users por item
|
||||
$items = Item::where('adminID', \Auth::id())->get();
|
||||
return view('item.index', compact('items'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the included item into database
|
||||
* As the items are included on the Product view,
|
||||
* it must return to there after inclusion
|
||||
*
|
||||
* @return (view) The product view
|
||||
*/
|
||||
public function store()
|
||||
{
|
||||
$this->validate(request(), ['name' => 'required']);
|
||||
Item::create(['name' => request('item'), 'productID' => request('productID')]); //Just remember to add the fillable on Model to make this work
|
||||
|
||||
return redirect('product');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ use \App\User;
|
||||
|
||||
class ProductController extends Controller
|
||||
{
|
||||
//
|
||||
public function index()
|
||||
{
|
||||
$products = Product::where('adminID', \Auth::id())->get();
|
||||
|
||||
Reference in New Issue
Block a user