@props([ 'items', 'columns', 'actions' => null, 'enableColumnFilters' => false, 'rowClass' => null, 'bulkSelectField' => null, 'bulkSelectName' => 'sector_ids[]', 'bulkSelectCheckboxClass' => 'js-bulk-row-select', ]) @if($bulkSelectField) @endif @foreach($columns as $column) @php $sortBy = $column['sort_by'] ?? null; $currentSort = request('sort'); $currentDirection = request('direction', 'asc'); @endphp @if($sortBy) @php $nextDirection = ($currentSort === $sortBy && $currentDirection === 'asc') ? 'desc' : 'asc'; $sortUrl = request()->fullUrlWithQuery([ 'sort' => $sortBy, 'direction' => $nextDirection, ]); @endphp {{ $column['label'] }} @if($currentSort === $sortBy) {{ $currentDirection === 'asc' ? '↑' : '↓' }} @else ↕ @endif @else {{ $column['label'] }} @endif @endforeach @isset($actions) Ações @endisset @if($enableColumnFilters) @foreach($columns as $column) @endforeach @isset($actions) @endisset @endif @forelse($items as $item) @php $computedRowClass = $rowClass ? (string) $rowClass($item) : ''; $rowFilterValues = []; foreach ($columns as $col) { $rawValue = data_get($item, $col['field']); $colType = $col['type'] ?? 'text'; if ($colType === 'datetime') { $rowFilterValues[] = $rawValue ? \Illuminate\Support\Carbon::parse($rawValue)->timezone(config('app.timezone'))->format('d/m/Y H:i') : '—'; continue; } if ($colType === 'allocation-holder') { $holder = (string) (data_get($item, 'holder_label') ?? '—'); $allocatedAt = (string) (data_get($item, 'holder_allocated_at_label') ?? ''); $rowFilterValues[] = trim($holder.' '.$allocatedAt); continue; } if ($colType === 'battery-progress') { $eligible = (int) data_get($item, 'progress_eligible', 0); $started = (int) data_get($item, 'progress_started', 0); $pending = (int) data_get($item, 'progress_pending', 0); $percent = (int) data_get($item, 'progress_percent', 0); $rowFilterValues[] = $eligible === 0 ? '—' : "{$percent}% {$started} iniciaram {$pending} pendentes de {$eligible}"; continue; } $rowFilterValues[] = is_scalar($rawValue) || $rawValue === null ? (string) ($rawValue ?? '—') : (string) json_encode($rawValue); } @endphp @if($bulkSelectField) @can('delete', $item) @endcan @endif @foreach($columns as $column) @php $value = data_get($item, $column['field']); $type = $column['type'] ?? 'text'; @endphp @switch($type) @case('status') @break @case('account-kind') @php $kind = $value instanceof \App\Enums\AccountKind ? $value : \App\Enums\AccountKind::tryFrom((string) $value); @endphp {{ $kind === \App\Enums\AccountKind::PORTAL_ONLY ? 'Portal' : ($kind === \App\Enums\AccountKind::STAFF ? 'Equipe' : '—') }} @break @case('equipment-availability') @break @case('datetime') {{ $value ? \Illuminate\Support\Carbon::parse($value)->timezone(config('app.timezone'))->format('d/m/Y H:i') : '—' }} @break @case('allocation-holder') @break @case('battery-progress') @php $progressEligible = (int) data_get($item, 'progress_eligible', 0); $progressStarted = (int) data_get($item, 'progress_started', 0); $progressPending = (int) data_get($item, 'progress_pending', 0); $progressPercent = (int) data_get($item, 'progress_percent', 0); @endphp @if($progressEligible === 0) — @else Início da bateria {{ $progressPercent }}% {{ $progressStarted }} iniciaram · {{ $progressPending }} pendentes de {{ $progressEligible }} na bateria @endif @break @default {{ $value }} @endswitch @endforeach @if($actions) {!! $actions($item) !!} @endif @empty @php $emptyColspan = count($columns) + ($bulkSelectField ? 1 : 0) + (isset($actions) ? 1 : 0); @endphp Nenhum registro encontrado @endforelse @if($bulkSelectField) @once @push('scripts') @endpush @endonce @endif
{{ $progressStarted }} iniciaram · {{ $progressPending }} pendentes
de {{ $progressEligible }} na bateria