$record->last_name, ]; } public static function getNavigationIcon(): \BackedEnum|string|null { return 'heroicon-o-user-circle'; } public static function getNavigationGroup(): ?string { return __('navigation.groups.clinic'); } public static function getNavigationSort(): ?int { return 1; } public static function getNavigationLabel(): string { return __('navigation.doctors.title'); } public static function getModelLabel(): string { return __('navigation.doctors.singular'); } public static function getPluralModelLabel(): string { return __('navigation.doctors.title'); } public static function form(Schema $schema): Schema { return $schema ->components([ Grid::make() ->schema([ Section::make() ->schema([ TextInput::make('first_name') ->label(__('doctors.fields.first_name')) ->required() ->maxLength(50), TextInput::make('last_name') ->label(__('doctors.fields.last_name')) ->required() ->maxLength(50), TextInput::make('speciality') ->label(__('doctors.fields.speciality')) ->maxLength(100), TextInput::make('license_id') ->label(__('doctors.fields.license_id')) ->maxLength(50), ]) ->columns(2) ->columnSpanFull() ->footerActions([ fn (string $operation) => Action::make('create') ->label(__('filament-panels::resources/pages/create-record.form.actions.create.label')) ->submit('create') ->keyBindings(['mod+s']) ->visible($operation === 'create'), fn (string $operation) => Action::make('createAnother') ->label(__('filament-panels::resources/pages/create-record.form.actions.create_another.label')) ->action('createAnother') ->keyBindings(['mod+shift+s']) ->color('gray') ->visible($operation === 'create'), fn (string $operation) => Action::make('cancelCreate') ->label(__('filament-panels::resources/pages/create-record.form.actions.cancel.label')) ->url(static::getUrl('index')) ->color('gray') ->visible($operation === 'create'), fn (string $operation) => Action::make('save') ->label(__('filament-panels::resources/pages/edit-record.form.actions.save.label')) ->submit('save') ->keyBindings(['mod+s']) ->visible($operation === 'edit'), fn (string $operation) => Action::make('cancelEdit') ->label(__('filament-panels::resources/pages/edit-record.form.actions.cancel.label')) ->url(static::getUrl('index')) ->color('gray') ->visible($operation === 'edit'), ]), ]) ->columnSpanFull(), ]); } public static function table(Table $table): Table { return $table ->columns([ TextColumn::make('first_name') ->label(__('doctors.fields.first_name')) ->weight(FontWeight::Medium) ->searchable() ->sortable(), TextColumn::make('last_name') ->label(__('doctors.fields.last_name')) ->weight(FontWeight::Medium) ->searchable() ->sortable(), TextColumn::make('speciality') ->label(__('doctors.fields.speciality')) ->searchable() ->sortable(), TextColumn::make('license_id') ->label(__('doctors.fields.license_id')) ->badge() ->color('primary'), TextColumn::make('created_at') ->label(__('doctors.fields.created_at')) ->sortable(), ]) ->defaultSort('last_name') ->recordActions([ EditAction::make(), DeleteAction::make(), ]) ->toolbarActions([ BulkActionGroup::make([ DeleteBulkAction::make(), BulkAction::make('export_excel_selected') ->label(__('table.export_excel_selected')) ->icon('heroicon-o-table-cells') ->color('success') ->action(function (Collection $records) { $tempPath = tempnam(sys_get_temp_dir(), 'export_') . '.xlsx'; $writer = new Writer(); $writer->openToFile($tempPath); $writer->addRow(Row::fromValues([ 'ID', __('doctors.fields.first_name'), __('doctors.fields.last_name'), __('doctors.fields.speciality'), __('doctors.fields.license_id'), __('doctors.fields.created_at'), ])); foreach ($records as $record) { $writer->addRow(Row::fromValues([ $record->id, $record->first_name, $record->last_name, $record->speciality, $record->license_id, $record->created_at, ])); } $writer->close(); return response()->streamDownload(function () use ($tempPath) { readfile($tempPath); @unlink($tempPath); }, 'doctors-' . now()->format('Y-m-d') . '.xlsx', [ 'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', ]); }), ]), ActionGroup::make([ Action::make('export_excel') ->label(__('table.export_excel')) ->color('success') ->icon('heroicon-o-table-cells') ->action(function () { $records = Doctor::all(); $tempPath = tempnam(sys_get_temp_dir(), 'export_') . '.xlsx'; $writer = new Writer(); $writer->openToFile($tempPath); $writer->addRow(Row::fromValues([ 'ID', __('doctors.fields.first_name'), __('doctors.fields.last_name'), __('doctors.fields.speciality'), __('doctors.fields.license_id'), __('doctors.fields.created_at'), ])); foreach ($records as $record) { $writer->addRow(Row::fromValues([ $record->id, $record->first_name, $record->last_name, $record->speciality, $record->license_id, $record->created_at, ])); } $writer->close(); return response()->streamDownload(function () use ($tempPath) { readfile($tempPath); @unlink($tempPath); }, 'doctors-' . now()->format('Y-m-d') . '.xlsx', [ 'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', ]); }), Action::make('export_pdf') ->label(__('table.export_pdf')) ->color('danger') ->icon('heroicon-o-document-arrow-down') ->action(function () { $records = Doctor::all(); return PdfService::download( 'exports.doctors-pdf', ['records' => $records], 'doctors-' . now()->format('Y-m-d') . '.pdf', ); }), ]) ->label(__('table.export')) ->color('orange') ->button(), ]); } public static function getPages(): array { return [ 'index' => Pages\ListDoctors::route('/'), 'create' => Pages\CreateDoctor::route('/create'), 'edit' => Pages\EditDoctor::route('/{record}/edit'), ]; } }