components([ Select::make('document_type') ->options(DocumentType::class) ->required() ->native(false), TextInput::make('title') ->required() ->maxLength(255), HrForm::fileUpload('file_path') ->label(__('hr.fields.document')) ->required() ->acceptedFileTypes(['application/pdf', 'image/*', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document']) ->maxSize(15360), ]); } public function table(Table $table): Table { return $table ->recordTitleAttribute('title') ->columns([ TextColumn::make('document_type') ->label(__('hr.fields.type')) ->badge() ->color(fn (DocumentType $state): string => $state->color()) ->formatStateUsing(fn (DocumentType $state): string => $state->label()) ->sortable(), TextColumn::make('title') ->searchable() ->sortable(), TextColumn::make('uploaded_at') ->dateTime() ->sortable() ->toggleable(isToggledHiddenByDefault: true), ]) ->filters([ SelectFilter::make('document_type') ->label(__('hr.fields.type')) ->options(DocumentType::class), TrashedFilter::make(), ]) ->headerActions([ CreateAction::make(), ]) ->recordActions([ Action::make('download') ->label(__('hr.actions.download')) ->icon('heroicon-o-arrow-down-tray') ->visible(fn (EmployeeDocument $record): bool => filled($record->file_path)) ->action(function (EmployeeDocument $record) { $disk = Storage::disk(config('hr.file_uploads.disk')); return response()->download( $disk->path($record->file_path), basename($record->file_path), ); }), EditAction::make(), DeleteAction::make(), ]) ->toolbarActions([ BulkActionGroup::make([ DeleteBulkAction::make(), ForceDeleteBulkAction::make(), RestoreBulkAction::make(), ]), ]); } }