@php // * Route vars $routeName = request()->route()?->getName() ?? 'noroute'; // * Default sort vars $defaultSortCol = $defaultSortCol ?? 'order'; $defaultSortWay = $defaultSortWay ?? 'asc'; $defaultSortWayStr = $defaultSortWay instanceof \SortDirection ? ($defaultSortWay === \SortDirection::Descending ? 'desc' : 'asc') : (string) $defaultSortWay; // * Request vars $currentSortCol = session()->get("{$routeName}.sort_col", $defaultSortCol); $currentSortWay = session()->get("{$routeName}.sort_way", $defaultSortWayStr); $searchQuery = request()->input('search'); // * Vue vars $noOrder = $noOrder ?? false; $ignore = isset($ignore) && is_array($ignore) ? $ignore : []; // * Hide order column $sortColIsOrder = $currentSortCol === 'order'; $noOrder = $noOrder || (!$sortColIsOrder && $currentSortCol) || !empty($searchQuery); View::share('noOrder', $noOrder); // * Reset button $hasCustomSort = ($currentSortCol && $currentSortCol !== $defaultSortCol) || ($currentSortCol === $defaultSortCol && $currentSortWay !== $defaultSortWayStr); $showReset = !empty($searchQuery) || $hasCustomSort; @endphp @foreach ($cols as $col => $colname) @php $iArgs = ['sort_col' => $col]; if ($searchQuery) { $iArgs['search'] = $searchQuery; } $isCurrentCol = $currentSortCol === $col; $mobileHiddenClass = isset($mobileHide) && is_array($mobileHide) && in_array($col, $mobileHide) ? 'd-none d-md-table-cell text-center' : ''; @endphp {{-- NO Sort for order column & ignored columns --}} @if ($col === 'order' || in_array($col, $ignore)) @if ($noOrder && $col === 'order') @continue @endif {{ $colname }} @continue @endif {{-- Sortable Columns --}} {{ $colname }} @if (!$isCurrentCol || $currentSortWay === 'desc') ↓ @endif @if (!$isCurrentCol || $currentSortWay === 'asc') ↑ @endif @endforeach {{-- Buttons Col --}} @if ($showReset) @else @endif