mirror of
https://github.com/brunofontes/shareit.git
synced 2025-11-15 16:00:54 -03:00
Imrpoving Item, Product and Users
This commit is contained in:
@@ -16,9 +16,18 @@
|
||||
|
||||
<h4>Your itens</h4>
|
||||
@forelse ($items as $item)
|
||||
<li>{{$item.name}}</li>
|
||||
<li>
|
||||
{{$item->name}}
|
||||
@if ($item->usedSince)
|
||||
<div class="alert">
|
||||
In use by {{$item->usedBy}}, since {{$item->usedSince->diffForHumans()}}
|
||||
</div>
|
||||
@else
|
||||
<a href="">TAKE IT</a>
|
||||
@endif
|
||||
</li>
|
||||
@empty
|
||||
<p>There are no items for you yet. Include one <a href="/product">here.</a></p>
|
||||
<p>There are no items for you yet. Include a product or an item <a href="/product">here.</a></p>
|
||||
@endforelse
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,44 @@
|
||||
<html>
|
||||
<h1>Item!</h1>
|
||||
<div>
|
||||
@if (isset($item))
|
||||
Item: {{$item}}
|
||||
@endif
|
||||
</html>
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
|
||||
<form method="POST" action="/item" class="form-inline">
|
||||
<div class="form-group">
|
||||
{{ csrf_field() }}
|
||||
<div class="col"><label for="product">Add Item: </label></div>
|
||||
<div class="col-6"><input type="text" class="form-control" name="item" id="item" placeholder="One Hundred Years of Solitude" required></div>
|
||||
<div class="col"><button type="submit" class="btn btn-primary">Insert</button></div>
|
||||
</div>
|
||||
@include ('layouts.errors')
|
||||
</form>
|
||||
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">
|
||||
Item: <strong>{{$item[0]->name}}</strong>
|
||||
@include ('item.buttons')
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
@if (session('status'))
|
||||
<div class="alert alert-success" role="alert"> {{ session('status') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<ul>
|
||||
@forelse ($otherItems as $otherItem)
|
||||
@if (!$otherItem->usedBy)
|
||||
<li><a href="/item/{{ $otherItem->id }}">{{ $otherItem->name }}</a></li>
|
||||
@endif
|
||||
@empty
|
||||
<p>There are no items yet. Include one with the form above.</p>
|
||||
@endforelse
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
22
resources/views/item/buttons.blade.php
Normal file
22
resources/views/item/buttons.blade.php
Normal 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 ($item[0]->admin_id == \Auth::id())
|
||||
<form action="/item/{{$item[0]->id}}" method="POST">
|
||||
@method('PATCH')
|
||||
<button type="button" class="btn-sm btn-secondary mr-1">Edit</button>
|
||||
</form>
|
||||
@endif
|
||||
|
||||
|
||||
<!-- DELETE BUTTON -->
|
||||
<form action="/item/{{$item[0]->id}}" method="POST">
|
||||
@method('DELETE')
|
||||
<button type="button" class="btn-sm btn-danger">Delete</button>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
</span>
|
||||
@@ -1,6 +0,0 @@
|
||||
<html>
|
||||
<h1>Product!</h1>
|
||||
@if (isset($productID))
|
||||
{{$productID}}
|
||||
@endif
|
||||
</html>
|
||||
@@ -10,6 +10,7 @@
|
||||
{{ csrf_field() }}
|
||||
<div class="col"><label for="product">Add Item: </label></div>
|
||||
<div class="col-6"><input type="text" class="form-control" name="item" id="item" placeholder="One Hundred Years of Solitude" required></div>
|
||||
<input type="hidden" name="product_id" id="product_id" value="{{ $product['id'] }}" required>
|
||||
<div class="col"><button type="submit" class="btn btn-primary">Insert</button></div>
|
||||
</div>
|
||||
@include ('layouts.errors')
|
||||
@@ -28,8 +29,8 @@
|
||||
@endif
|
||||
|
||||
<ul>
|
||||
@forelse ($items as $item)
|
||||
<li><a href="/product/{{$item['id']}}">{{$item['name']}}</a></li>
|
||||
@forelse ($product->items as $item)
|
||||
<li><a href="/item/{{ $item->id }}">{{ $item->name }}</a></li>
|
||||
@empty
|
||||
<p>There are no items yet. Include one with the form above.</p>
|
||||
@endforelse
|
||||
|
||||
@@ -96,7 +96,6 @@
|
||||
@auth
|
||||
<a href="/home">Home</a>
|
||||
<a href="/product">Products</a>
|
||||
<a href="/item">Items</a>
|
||||
@else
|
||||
<a href="/register">Register</a>
|
||||
<a href="/login">Login</a>
|
||||
|
||||
Reference in New Issue
Block a user