2018-09-09 04:03:41 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class HomeController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Create a new controller instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->middleware('auth');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the application dashboard.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
2018-09-11 23:48:09 +00:00
|
|
|
$items = \DB::table('items')
|
|
|
|
->join('item_user', 'item_user.item_id', '=', 'items.id')
|
2018-09-12 21:24:56 +00:00
|
|
|
->join('products', 'products.id', '=', 'items.id')
|
2018-09-11 23:48:09 +00:00
|
|
|
->where('item_user.user_id', \Auth::id())
|
2018-09-12 21:24:56 +00:00
|
|
|
->select('items.*', 'products.name as pname')
|
|
|
|
->orderBy('items.name')
|
2018-09-11 23:48:09 +00:00
|
|
|
->get();
|
2018-09-10 04:23:32 +00:00
|
|
|
return view('home', compact('items'));
|
2018-09-09 04:03:41 +00:00
|
|
|
}
|
|
|
|
}
|