@extends('back-end.master.app')
@section('title', 'productCategory')
@section('body')
    <main class="app-content">
        <div class="row">
            <div class="col-md-12">
                <div class="card">

                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-9">
                                <h3 class="">Categoires</h3>
                            </div>
                            <div class="col-md-3">
                                <button class="btn btn-primary btn-sm btn-rounded" style="float: right;" data-toggle="modal"
                                    data-target="#userModal">
                                    <i class="fa fa-plus"></i>New
                                </button>
                            </div>
                        </div>
                        <div class="row mt-5">
                            <div class="col-md-12">
                                <div class="table">
                                    <table class="table data_table">
                                        <thead>
                                            <tr>
                                                <th>No</th>
                                                <th>title En</th>
                                                <th>title ps</th>
                                                <th>title Dr</th>
                                                <th>Action</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @foreach ($category as $row)
                                                <tr style="padding:0px!important;">
                                                    <td>{{ $loop->iteration }}</td>
                                                    <td>{{ $row->title_en }}</td>
                                                    <td>{{ $row->title_ps }}</td>
                                                    <td>{{ $row->title_dr }}</td>
                                                    <td>
                                                        <a href="{{ route('categories.edit', $row->id) }}"><i
                                                                class="fa fa-edit"></i></a>
                                                    </td>
                                                </tr>
                                            @endforeach

                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="card">
                                <div class="card-body">
                                    {{ $category->links('pagination::bootstrap-4') }}
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </main>
    <!-- The Modal -->
    @include('back-end.categories.modal')
@endsection


@section('pageJs')
    <script type="text/javascript">
        $(".app-menu").removeClass("active");
        $("#nav_configi").addClass("active");
        $("#nav_configi").addClass("is-expanded");
        $("#nav_scat").addClass("active");
        $(document).on("click", ".btn-delete", function() {
            var id = $(this).attr("data-id");
            swal({
                title: "Are you sure want to delete?",
                text: "...",
                type: "warning",
                showCancelButton: true,
                confirmButtonText: "Yes!",
                cancelButtonText: "No!",
                closeOnConfirm: false,
                closeOnCancel: false
            }, function(isConfirm) {
                if (isConfirm) {
                    $('#delete-form').attr('action', url);
                    $("#delete-form").submit();
                } else {
                    swal("Cancelled", "Record not deleted", "error");
                    return false;
                }
            });
        });




        // for getting record

        $("#all").addClass("active");
    </script>
@endsection
