2018-09-09 03:26:57 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use \App\Item;
|
|
|
|
|
|
|
|
class ItemController extends Controller
|
|
|
|
{
|
2018-09-11 00:29:32 +00:00
|
|
|
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'));
|
|
|
|
}
|
|
|
|
|
2018-09-09 03:26:57 +00:00
|
|
|
public function index()
|
|
|
|
{
|
2018-09-11 00:29:32 +00:00
|
|
|
//TODO: Fazer innerjoint com tabela de users por item
|
|
|
|
$items = Item::where('adminID', \Auth::id())->get();
|
|
|
|
return view('item.index', compact('items'));
|
2018-09-09 03:26:57 +00:00
|
|
|
}
|
|
|
|
|
2018-09-11 00:29:32 +00:00
|
|
|
/**
|
|
|
|
* 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()
|
2018-09-09 03:26:57 +00:00
|
|
|
{
|
2018-09-11 00:29:32 +00:00
|
|
|
$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');
|
2018-09-09 03:26:57 +00:00
|
|
|
}
|
2018-09-11 00:29:32 +00:00
|
|
|
|
2018-09-09 03:26:57 +00:00
|
|
|
}
|