mirror of
https://github.com/brunofontes/shareit.git
synced 2024-11-24 04:14:57 +00:00
Adding product name with the item name on the Home page
This commit is contained in:
parent
8c0e46538c
commit
9f67cbcbeb
@ -25,8 +25,10 @@ class HomeController extends Controller
|
|||||||
{
|
{
|
||||||
$items = \DB::table('items')
|
$items = \DB::table('items')
|
||||||
->join('item_user', 'item_user.item_id', '=', 'items.id')
|
->join('item_user', 'item_user.item_id', '=', 'items.id')
|
||||||
|
->join('products', 'products.id', '=', 'items.id')
|
||||||
->where('item_user.user_id', \Auth::id())
|
->where('item_user.user_id', \Auth::id())
|
||||||
->select('items.*')
|
->select('items.*', 'products.name as pname')
|
||||||
|
->orderBy('items.name')
|
||||||
->get();
|
->get();
|
||||||
return view('home', compact('items'));
|
return view('home', compact('items'));
|
||||||
}
|
}
|
||||||
|
@ -17,13 +17,24 @@
|
|||||||
<h4>Your itens</h4>
|
<h4>Your itens</h4>
|
||||||
@forelse ($items as $item)
|
@forelse ($items as $item)
|
||||||
<li>
|
<li>
|
||||||
{{$item->name}}
|
<strong>{{$item->name}}</strong> ({{$item->pname}})
|
||||||
@if ($item->usedSince)
|
|
||||||
<div class="alert">
|
@if ($item->usedBy)
|
||||||
In use by {{$item->usedBy}}, since {{$item->usedSince->diffForHumans()}}
|
@if ($item->usedBy == \Auth::id())
|
||||||
</div>
|
<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
|
@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
|
@endif
|
||||||
</li>
|
</li>
|
||||||
@empty
|
@empty
|
||||||
|
Loading…
Reference in New Issue
Block a user