<x-app-layout>
    @section('title')
        Pages Management
    @endsection
    <!-- Page Heading -->
    <h1 class="h3 mb-2 text-gray-800">
        @can('blog create')
            <a href="{{ route('admin.product.create') }}" class="btn btn-primary"><i class="fas fa-plus" aria-hidden="true"></i>
                Add New Product
            </a>
        @endcan
    </h1>
    <!-- DataTales Example -->
    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-primary">
                Categories
            </h6>
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                    <thead>
                        <tr>
                            <th>No</th>
                            <th>Product name</th>
                            <th>image</th>
                            <th>Price</th>
                            <th>Sort description</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($datas as $data)
                            <tr>
                                <td>{{ $data->id }} </td>
                                <td>{{ $data->name }} </td>
                                <td> <img style="width: 60px" src="{{  asset($data->image)}}" alt=""> </td>
                                <td> {{ $data->price }} </td>
                                <td> {{ $data->sort_description }} </td>
                                <td>
                                    <div class="d-flex">
                                        @can('product edit')
                                        <a href="{{ route('admin.product.edit',$data->id) }}" class="btn btn-primary">Edit</a>
                                    @endcan

                                    @can('product delete')
                                        <form action="{{ route('admin.product.destroy',$data->id) }}" method="POST">
                                            @csrf
                                            @method('delete')
                                            <button type="submit" class="btn btn-danger ml-1">Delete</button>
                                        </form>
                                    @endcan
                                    </div>



                                </td>
                            </tr>
                        @endforeach

                    </tbody>
                </table>
            </div>
        </div>
    </div>
</x-app-layout>
