File: /var/www/kosmicfarms/resources/views/products/index.blade.php
@extends('layouts.app')
@section('content')
<div class="d-sm-flex align-items-center justify-content-between mg-b-20 mg-lg-b-25 mg-xl-b-30">
<div>
<nav aria-label="breadcrumb">
<ol class="breadcrumb breadcrumb-style1 mg-b-10">
<li class="breadcrumb-item"><a href="{{ url('/') }}">Dashboard</a></li>
<li class="breadcrumb-item active" aria-current="page">Products</li>
</ol>
</nav>
<h4 class="mg-b-0 tx-spacing--1">Products</h4>
</div>
<div class="d-none d-md-block">
<a href="{{ url('/products/create') }}" class="btn btn-sm pd-x-15 btn-white btn-uppercase"><i data-feather="mail" class="wd-10 mg-r-5"></i> Add Product</a>
</div>
</div>
<!-- ============================================================== -->
<!-- Content Start -->
<!-- ============================================================== -->
<h4 id="section2" class="mg-b-10">List of Products</h4>
<p class="mg-b-30">Products informations.</p>
<div class="row">
<div class="col-md-12">
<table id="products" class="table">
<thead>
<tr>
<th scope="col">Product Type</th>
<th scope="col">Category</th>
<th scope="col">Name</th>
<th scope="col">Quantity</th>
<th scope="col">Price</th>
<th scope="col">Farm</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
@if(isset($products))
@foreach($products as $product)_
<tr>
<td>@if(isset($product->producttype)){{ $product->producttype->name }}@endif</td>
<td>@if(isset($product->category)){{ $product->category->name }}@endif</td>
<td>{{ $product->name }}</td>
<td>{{ $product->quantity }}</td>
<td>{{ $product->price }}</td>
<td>{{ $product->farm }}</td>
<td>
<form method="post" action="{{ url('/products/'.$product->id.'/delete') }}" class="form-horizontal">
{!! csrf_field() !!}
<a href="{{ url('/products/'.$product->id.'/edit') }}" class="btn btn-warning btn-rounded">Edit</a>
<input type="hidden" name="delete" value="true">
<button type="submit" class="btn btn-danger btn-rounded" id="danger-alert">Delete</button>
</form>
</td>
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
</div>
<!-- ============================================================== -->
<!-- Content End -->
<!-- ============================================================== -->
@endsection
@section('jscript')
<script src="{{ asset('admin/lib/datatables.net/js/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('admin/lib/datatables.net-dt/js/dataTables.dataTables.min.js') }}"></script>
<script>
$(document).ready(function () {
$('#products').DataTable({
language: {
searchPlaceholder: 'Search...',
sSearch: '',
lengthMenu: '_MENU_ items/page',
}
});
});
</script>
@endsection