@php
    $query = request()->except(['sort_by', 'sort_dir', 'page']);
    $defaultSortBy = $defaultSortBy ?? 'dt_publicacao';
    $defaultSortDir = $defaultSortDir ?? 'desc';
    $isActive = request('sort_by', $defaultSortBy) === $column;
    $curDir = request('sort_dir', $defaultSortDir);
    $nextDir = $isActive && $curDir === 'asc' ? 'desc' : 'asc';
    $query['sort_by'] = $column;
    $query['sort_dir'] = $nextDir;
    $href = route($route ?? 'admin.legislacao.portarias.index', $query);
@endphp
<a href="{{ $href }}"
    class="text-decoration-none text-dark d-inline-flex flex-nowrap align-items-center justify-content-center gap-1 text-nowrap">
    <span>{{ $label }}</span>
    @if ($isActive)
        <span class="text-body flex-shrink-0" aria-hidden="true"><i class="fa fa-sort-{{ $curDir === 'asc' ? 'up' : 'down' }}"></i></span>
        <span class="visually-hidden">{{ $curDir === 'asc' ? __('Ordenar decrescente') : __('Ordenar crescente') }}</span>
    @else
        <span class="text-muted flex-shrink-0" aria-hidden="true"><i class="fa fa-sort"></i></span>
        <span class="visually-hidden">{{ __('Ordenar') }}</span>
    @endif
</a>
