@extends('admin.layouts.app')
@section('title', 'Sub Categories List')
@section('content')
    <div class="page-header">
        <div class="page-title">
            <h4>Sub Categories List</h4>
            <h6>Manage your sub categories</h6>
        </div>
        @if(auth()->user()->hasPermission('Sub Category Create'))
        <div class="page-btn">
            <a href="{{ route('sub-categories.create') }}" class="btn btn-added">
                <img src="{{ asset('assets/img/icons/plus.svg') }}" alt="img" class="me-1">Add Sub Category
            </a>
        </div>
        @endif
    </div>

    <div class="card">
        <div class="card-body">
            <div class="table-top">
                <div class="search-set">
                    <div class="search-input">
                        <a class="btn btn-searchset">
                            <img src="{{ asset('assets/img/icons/search-white.svg') }}" alt="img">
                        </a>
                    </div>
                </div>
            </div>
            <div class="table-responsive">
                <table class="table datanew dataTable no-footer table-striped">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Prefix</th>
                            @if(auth()->user()->hasPermission('Sub Category Update'))
                            <th>Action</th>
                            @endif
                            <th>Name</th>
                            <th>Category</th>
                            
                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($subCategories as $subCategory)
                            <tr>
                                <td>{{ $loop->iteration }}</td>
                                <td><a class="link-primary" href="{{ route('sub-categories.show', $subCategory->id) }}">{{ $subCategory->prefix }}</a></td>
                                @if(auth()->user()->hasPermission('Sub Category Update'))
                                <td>
                                    <a class="me-3" href="{{ route('sub-categories.edit', $subCategory->id) }}">
                                        <img src="{{ asset('assets/img/icons/edit.svg') }}" alt="Edit">
                                    </a>
                                </td>
                                @endif
                                <td>{{ $subCategory->name }}</td>
                                <td>{{ $subCategory->category->name }}</td>
                                
                            </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
@endsection