@props([ 'items', // the collection (e.g., $airports, $users) 'columns' => [], // array of [ 'label' => 'Name', 'field' => 'name', 'class' => '' ] 'itemRoute' => null, 'itemActions' => [], 'currentSort' => null, 'currentDir' => 'asc', ])
@foreach ($columns as $col) @php $field = $col['field']; $isSorted = $currentSort === $field; $newDir = ($isSorted && $currentDir === 'asc') ? 'desc' : 'asc'; @endphp @endforeach @forelse($items as $item) {{-- Edit --}} {{-- Data cells --}} @foreach($columns as $col)
  @if(!empty($field)) {{ $col['label'] }} @if ($isSorted) @if ($currentDir === 'asc') ▲ @else ▼ @endif @endif @else {{ $col['label'] }} @endif  
@if(in_array('edit', $itemActions)) Edit @endif