@php use App\Enums\RecordStatus; use App\Helpers\PermissionHelper; $tableId = str($routePrefix)->replace('.', '-')->slug(); $breadcrumbs = $breadcrumbs ?? [ ['label' => 'Home', 'href' => route('dashboard')], ['label' => 'Institution Setup', 'href' => route('institution.dashboard')], ['label' => $resourceLabel], ]; $columns = $columns ?? [ ['key' => 'code', 'label' => 'Code'], ['key' => 'name', 'label' => 'Name'], ['key' => 'status', 'label' => 'Status', 'render' => 'status'], ]; $canBulk = PermissionHelper::can($permissionPrefix . '.view'); @endphp @include('institution.partials.table-toolbar') @include('institution.partials.flash') @include('institution.partials.stats-row', ['stats' => $stats]) @include('institution.partials.filters')
@csrf
@include('institution.partials.table-toolbar') @if($canBulk) @endif @foreach($columns as $column) {{ $column['label'] }} @endforeach Actions @forelse($records as $record) trashed()) class="table-secondary" @endif> @if($canBulk) @endif @foreach($columns as $column) @php $render = $column['render'] ?? 'text'; $value = data_get($record, $column['key']); @endphp @switch($render) @case('status') @php $status = is_object($record->status) ? $record->status : RecordStatus::tryFrom($record->status ?? 'active'); @endphp @break @case('enum') @php $enumVal = is_object($value) ? $value : null; @endphp {{ $enumVal?->label() ?? ucfirst(str_replace('_', ' ', (string) $value)) }} @break @case('date') {{ $value ? \Illuminate\Support\Carbon::parse($value)->format('d M Y') : '—' }} @break @case('datetime') {{ $value ? \Illuminate\Support\Carbon::parse($value)->format('d M Y, H:i') : '—' }} @break @case('boolean') {{ $value ? 'Yes' : 'No' }} @break @case('relation') {{ data_get($record, $column['relation'] ?? $column['key']) ?? '—' }} @break @case('badge') {{ $value ?? '—' }} @break @default {{ $value ?? '—' }} @endswitch @endforeach @include('institution.partials.row-actions', ['record' => $record]) @empty @endforelse @if($records->hasPages()) {{ $records->links() }} @endif @push('scripts') @vite('resources/js/pages/tables.js') @endpush