@extends('layouts.app')

@section('title', 'Category List')

@section('content')
    <div class="container-fluid">

        <!-- Page Heading -->
        <div class="d-sm-flex align-items-center justify-content-between mb-4">
            <h1 class="h3 mb-0 text-gray-800">Categories</h1>
            <div class="row">
                <div class="col-md-6">
                    <a href="{{ route('categorylist.createcategory') }}" class="btn btn-sm btn-primary">
                        <i class="fas fa-plus"></i> Add New
                    </a>
                </div>
                <div class="col-md-6">
                    <a href="#" class="btn btn-sm btn-success">
                        <i class="fas fa-check"></i> Export To Excel
                    </a>
                </div>
                
            </div>

        </div>

        {{-- Alert Messages --}}
        @include('common.alert')

        <!-- DataTales Example -->
        <div class="card shadow mb-4">
            <div class="card-header py-3">
                <h6 class="m-0 font-weight-bold text-primary">Category List</h6>

            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                        <thead>
                            <tr>
                                <th width="20%">Category</th>
                                <th width="25%">Description</th>
                                <th width="15%">Status</th>
                            <th width="10%">Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach ($categories as $row)
                           
                                <tr>
                                    <td>{{ $row->category }}</td>
                                    <td>{{ $row->descriptions }}</td>
                                    
                                    
                                    <td>
                                        @if ($row->status == 0)
                                            <span class="badge badge-danger">Inactive</span>
                                        @elseif ($row->status == 1)
                                            <span class="badge badge-success">Active</span>
                                        @endif
                                    </td>
                                    <td style="display: flex">
                                        @if ($row->status == 0)
                                            <a href="{{ route('categorylist.updatecategoryStatus', ['id' => $row->id, 'status' => 1]) }}"
                                                class="btn btn-success m-2">
                                                <i class="fa fa-check"></i>
                                            </a>
                                        @elseif ($row->status == 1)
                                            <a href="{{ route('categorylist.updatecategoryStatus', ['id' => $row->id, 'status' => 0]) }}"
                                                class="btn btn-danger m-2">
                                                <i class="fa fa-ban"></i>
                                            </a> 
                                        @endif
                                        <a href="{{route('categorylist.Categoryedit', ['id' => $row->id]) }}"class="btn btn-primary m-2">
                                            <i class="fa fa-pen"></i>
                                        </a> 
                                        <a class="btn btn-danger m-2" href="#" data-toggle="modal" data-target="#deletecategoryModal">
                                            <i class="fas fa-trash"></i>
                                        </a>
                                         
                                    </td>
                                </tr>
                            @endforeach
                        </tbody>
                    </table>

                    {{ $categories->links() }}
                </div>
            </div>
        </div>

    </div>

    @if ($categories->count() > 0 )
@if(isset($categories) && !empty($categories))

    @include('category.delete-categoryModel')
    
@endif
@endif
    


@endsection

@section('scripts')
    
@endsection
