@extends('admin.layouts.app')
@section('panel')
    <div class="row">

        <div class="col-lg-12">
            <div class="show-filter mb-3 text-end">
                <button type="button" class="btn btn-outline--primary showFilterBtn btn-sm"><i class="las la-filter"></i>
                    @lang('Filter')</button>
            </div>
            <div class="card responsive-filter-card mb-4">
                <div class="card-body">
                    <form action="">
                        <div class="d-flex flex-wrap gap-4">
                            <div class="flex-grow-1">
                                <label>@lang('Name')</label>
                                <input type="text" name="search" value="{{ request()->search }}" class="form-control">
                            </div>

                            <div class="flex-grow-1 align-self-end">
                                <button class="btn btn--primary w-100 h-45"><i class="fas fa-filter"></i>
                                    @lang('Filter')</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>



            <div class="card b-radius--10 ">
                <div class="card-body p-0">
                    <div class="table-responsive--md  table-responsive">
                        <table class="table table--light style--two">
                            <thead>
                                <tr>
                                    <th>@lang('Permissions')</th>
                                    <th>@lang('Associated Roles')</th>
                                    <th>@lang('Action')</th>
                                </tr>
                            </thead>
                            <tbody>
                                @forelse($permissions as $permission)
                                    <tr>
                                        <td>
                                            <span class="fw-bold">{{ Str::title($permission->name) }}</span>
                                            <br>
                                            <span class="small">{{ $permission->guard_name }}</span>
                                        </td>

                                        <td>
                                        <div>
                                            @forelse($permission->roles as $r)
                                                <span class="badge badge--primary">{{ $r->name }}</span>
                                            @empty
                                                --
                                            @endforelse
                                        </div>
                                        </td>

                                        <td>
                                            <button
                                                data-action="{{ route('admin.access.permissions.view', $permission->id) }}"
                                                data-title="@lang('View'): {{ __($permission->name) }} "
                                                class="btn btn-sm btn-outline--primary formModalBtn">
                                                <i class="las la-desktop text--shadow"></i> @lang('View')
                                            </button>
                                        </td>

                                    </tr>
                                @empty
                                    <tr>
                                        <td class="text-muted text-center" colspan="100%">{{ __($emptyMessage) }}</td>
                                    </tr>
                                @endforelse

                            </tbody>
                        </table>
                    </div>
                </div>
                @if ($permissions->hasPages())
                    <div class="card-footer py-4">
                        {{ paginateLinks($permissions) }}
                    </div>
                @endif
            </div>
        </div>

        <x-form-modal />
    </div>
@endsection



@push('breadcrumb-plugins')
    <button data-action="{{ route('admin.access.roles.create-edit') }}" data-title="@lang('Create Role')"
        class="btn btn-sm btn-outline--primary formModalBtn"><i class="fas fa-plus"></i> Add
        Role</button>
@endpush

@push('style-lib')
    <link rel="stylesheet" href="{{ asset('assets/admin/css/vendor/datepicker.min.css') }}">
@endpush


@push('script-lib')
    <script src="{{ asset('assets/admin/js/vendor/datepicker.min.js') }}"></script>
    <script src="{{ asset('assets/admin/js/vendor/datepicker.en.js') }}"></script>
@endpush

@push('script')
@endpush
