mirror of
https://github.com/brunofontes/shareit.git
synced 2025-11-15 16:00:54 -03:00
Including occupied username and renaming DB field
Now it shows the username of who is using an item. Item db field 'usedBy' was renamed to 'used_by' to keep consistence.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-header">Dashboard</div>
|
||||
<div class="card-header"><h3>Your items</h3></div>
|
||||
|
||||
<div class="card-body">
|
||||
@if (session('status'))
|
||||
@@ -14,37 +14,21 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<h4>Your itens</h4>
|
||||
@forelse ($items as $item)
|
||||
<hr class="ml-5 mr-5">
|
||||
<li class="mt-1 mb-1">
|
||||
@if (!$loop->first)
|
||||
<hr class="m-3">
|
||||
@endif
|
||||
<div class="my-4 p-2">
|
||||
<strong>{{$item->name}}</strong> ({{$item->product->name}})
|
||||
|
||||
@if ($item->usedBy)
|
||||
@if ($item->usedBy == \Auth::id())
|
||||
<span class="float-right">
|
||||
<form action="/return" method="POST">
|
||||
{{ csrf_field() }}
|
||||
<input type="hidden" name="item" value="{{$item->id}}">
|
||||
<button type="submit" class="btn-xm btn-danger">Return It</button>
|
||||
</form>
|
||||
</span>
|
||||
<span class="float-right mr-3"><em>{{\Carbon\Carbon::parse($item->updated_at)->diffForHumans()}}</em></span>
|
||||
@else
|
||||
<div class="alert alert-danger" role="alert">In use by {{$item->usedBy}}, since {{$item->updated_at->diffForHumans()}}</div>
|
||||
@endif
|
||||
@if ($item->used_by)
|
||||
@include('home.usedItem')
|
||||
@else
|
||||
<span class="float-right">
|
||||
<form action="/take" method="POST">
|
||||
{{ csrf_field() }}
|
||||
<input type="hidden" name="item" value="{{$item->id}}">
|
||||
<button type="submit" class="btn-xm btn-success">Take It</button>
|
||||
</form>
|
||||
</span>
|
||||
@include('home.unusedItem')
|
||||
@endif
|
||||
</li>
|
||||
</div>
|
||||
@empty
|
||||
<p>There are no items for you yet. Include a product or an item <a href="/product">here.</a></p>
|
||||
<p>There are no items shared with you yet. <a href="/product">Share an item!</a></p>
|
||||
@endforelse
|
||||
</div>
|
||||
</div>
|
||||
|
||||
7
resources/views/home/unusedItem.blade.php
Normal file
7
resources/views/home/unusedItem.blade.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<span class="float-right">
|
||||
<form action="/take" method="POST">
|
||||
{{ csrf_field() }}
|
||||
<input type="hidden" name="item" value="{{$item->id}}">
|
||||
<button type="submit" class="btn btn-sm btn-success">Take It</button>
|
||||
</form>
|
||||
</span>
|
||||
21
resources/views/home/usedItem.blade.php
Normal file
21
resources/views/home/usedItem.blade.php
Normal file
@@ -0,0 +1,21 @@
|
||||
@if ($item->used_by == \Auth::id())
|
||||
<span class="float-right">
|
||||
<form action="/return" method="POST">
|
||||
{{ csrf_field() }}
|
||||
<input type="hidden" name="item" value="{{$item->id}}">
|
||||
<button type="submit" class="btn btn-sm btn-danger">Return It</button>
|
||||
</form>
|
||||
</span>
|
||||
<span class="float-right mr-3"><em>{{\Carbon\Carbon::parse($item->updated_at)->diffForHumans()}}</em></span>
|
||||
@else
|
||||
<span class="float-right">
|
||||
<form action="/alert" method="POST">
|
||||
{{ csrf_field() }}
|
||||
<input type="hidden" name="item" value="{{$item->id}}">
|
||||
<button type="submit" class="btn btn-sm btn-outline-secondary">Alert me</button>
|
||||
</form>
|
||||
</span>
|
||||
<span class="float-right mr-3">
|
||||
<em>{{str_limit($users[$item->used_by], 15, '...')}} ({{$item->updated_at->diffForHumans()}})</em>
|
||||
</span>
|
||||
@endif
|
||||
@@ -19,7 +19,7 @@
|
||||
<strong>Other items from the same product:</strong>
|
||||
<ul>
|
||||
@forelse ($otherItems as $otherItem)
|
||||
@if (!$otherItem->usedBy)
|
||||
@if (!$otherItem->used_by)
|
||||
<li><a href="/item/{{ $otherItem->id }}">{{ $otherItem->name }}</a></li>
|
||||
@endif
|
||||
@empty
|
||||
|
||||
Reference in New Issue
Block a user