setPrimaryKey('id') ->setDefaultSort('inspections.created_at', 'desc') ->setSortingPillsEnabled(false) ->setSecondaryHeaderEnabled() ->setAdditionalSelects([ 'inspections.id as id', 'inspections.created_at as created_at', 'inspections.feature_id as feature_id', 'inspections.template_id as template_id', 'inspections.user_id as user_id', ]); } public function builder(): Builder { $user = Auth::user(); abort_unless( $user->can('manage all') || Project::whereKey($this->projectId)->whereHas('users', fn ($q) => $q->where('user_id', $user->id))->exists(), 403 ); return Inspection::query() ->where('inspections.project_id', $this->projectId) ->with(['feature', 'template', 'user']); } public function columns(): array { return [ Column::make('Fecha', 'created_at') ->sortable() ->secondaryHeaderFilter('fecha') ->format(fn ($value, $row) => $row->created_at?->format('d/m/Y') ?? '—'), Column::make('Elemento') ->secondaryHeaderFilter('elemento') ->label(fn ($row) => $row->feature?->name ? '' . e($row->feature->name) . '' : '—') ->html(), Column::make('Plantilla') ->label(fn ($row) => e($row->template?->name ?? '—')), Column::make('Resultado', 'result') ->sortable() ->secondaryHeaderFilter('resultado') ->format(fn ($value) => $value ? '' . e($value) . '' : '—') ->html(), Column::make('Usuario') ->secondaryHeaderFilter('usuario') ->label(fn ($row) => e($row->user?->name ?? '—')), Column::make('Acciones') ->label(fn ($row) => '