Refactoring product view

Creating a separate buttons file to edit or delete a product
This commit is contained in:
Bruno F. Fontes 2018-09-12 21:28:39 -03:00
parent 9debf5548c
commit 73e8b5e4b4
2 changed files with 24 additions and 1 deletions

View File

@ -0,0 +1,22 @@
<span class="d-inline-block text-truncat float-right">
<div class="btn-group btn-group-sm" role="group">
<!-- EDIT BUTTON -->
@if ($product->user_id == \Auth::id())
<form action="/product/{{$product->id}}" method="POST">
@method('PATCH')
<button type="button" class="btn-sm btn-secondary mr-1">Edit</button>
</form>
@endif
<!-- DELETE BUTTON -->
<form action="/product/{{$product->id}}" method="POST">
@method('DELETE')
<button type="button" class="btn-sm btn-danger">Delete</button>
</form>
</div>
</span>

View File

@ -19,7 +19,7 @@
<div class="card mt-4"> <div class="card mt-4">
<div class="card-header"> <div class="card-header">
Product: <strong>{{$product['name']}}</strong> Product: <strong>{{$product['name']}}</strong>
<span class="d-inline-block text-truncat float-right">Edit - Delete</span> @include ('product.buttons')
</div> </div>
<div class="card-body"> <div class="card-body">
@ -28,6 +28,7 @@
</div> </div>
@endif @endif
<strong>Items:</strong>
<ul> <ul>
@forelse ($product->items as $item) @forelse ($product->items as $item)
<li><a href="/item/{{ $item->id }}">{{ $item->name }}</a></li> <li><a href="/item/{{ $item->id }}">{{ $item->name }}</a></li>