mirror of
https://github.com/brunofontes/shareit.git
synced 2024-11-23 20:10:52 +00:00
Adding product name with the item name on the Home page
This commit is contained in:
parent
982d0bbc9e
commit
b41b9b4557
@ -25,8 +25,10 @@ class HomeController extends Controller
|
||||
{
|
||||
$items = \DB::table('items')
|
||||
->join('item_user', 'item_user.item_id', '=', 'items.id')
|
||||
->join('products', 'products.id', '=', 'items.id')
|
||||
->where('item_user.user_id', \Auth::id())
|
||||
->select('items.*')
|
||||
->select('items.*', 'products.name as pname')
|
||||
->orderBy('items.name')
|
||||
->get();
|
||||
return view('home', compact('items'));
|
||||
}
|
||||
|
@ -17,13 +17,24 @@
|
||||
<h4>Your itens</h4>
|
||||
@forelse ($items as $item)
|
||||
<li>
|
||||
{{$item->name}}
|
||||
@if ($item->usedSince)
|
||||
<div class="alert">
|
||||
In use by {{$item->usedBy}}, since {{$item->usedSince->diffForHumans()}}
|
||||
</div>
|
||||
<strong>{{$item->name}}</strong> ({{$item->pname}})
|
||||
|
||||
@if ($item->usedBy)
|
||||
@if ($item->usedBy == \Auth::id())
|
||||
<span class="float-right">
|
||||
<form action="/item/{{$item->id}}" method="POST">
|
||||
<button type="button" class="btn btn-danger" disabled>Return It</button>
|
||||
</form>
|
||||
</span>
|
||||
@else
|
||||
<div class="alert alert-danger" role="alert">In use by {{$item->usedBy}}, since {{$item->usedSince->diffForHumans()}}</div>
|
||||
@endif
|
||||
@else
|
||||
<a href="">TAKE IT</a>
|
||||
<span class="float-right">
|
||||
<form action="/item/{{$item->id}}" method="POST">
|
||||
<button type="button" class="btn btn-success">Take It</button>
|
||||
</form>
|
||||
</span>
|
||||
@endif
|
||||
</li>
|
||||
@empty
|
||||
|
Loading…
Reference in New Issue
Block a user