components([ Grid::make() ->schema([ Section::make(__('medications.sections.info')) ->schema([ TextInput::make('name') ->label(__('medications.fields.name')) ->required() ->maxLength(255), TextInput::make('dosage_form') ->label(__('medications.fields.dosage_form')) ->maxLength(50) ->placeholder('Tab, Cap, Amp, Drop, Serum, Cream ...'), TextInput::make('strength') ->label(__('medications.fields.strength')) ->maxLength(100) ->placeholder('500mg, 5mg/5ml ...'), TextInput::make('quantity') ->label(__('medications.fields.quantity')) ->numeric() ->minValue(0), TextInput::make('timing') ->label(__('medications.fields.timing')) ->maxLength(100) ->placeholder('q8h, q12h, q24h ...'), Textarea::make('notes') ->label(__('medications.fields.notes')) ->rows(2) ->columnSpanFull(), Toggle::make('is_default') ->label(__('medications.fields.is_default')), Toggle::make('is_active') ->label(__('medications.fields.is_active')) ->default(true), ]) ->columns(3) ->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('name') ->label(__('medications.fields.name')) ->searchable() ->sortable(), TextColumn::make('dosage_form') ->label(__('medications.fields.dosage_form')) ->badge() ->placeholder('-'), TextColumn::make('strength') ->label(__('medications.fields.strength')) ->placeholder('-'), TextColumn::make('quantity') ->label(__('medications.fields.quantity')) ->placeholder('-'), TextColumn::make('timing') ->label(__('medications.fields.timing')) ->placeholder('-'), IconColumn::make('is_default') ->label(__('medications.fields.is_default')) ->boolean(), IconColumn::make('is_active') ->label(__('medications.fields.is_active')) ->boolean(), TextColumn::make('created_at') ->label(__('medications.fields.created_at')) ->sortable(), ]) ->defaultSort('name') ->recordActions([ EditAction::make(), DeleteAction::make(), ]) ->toolbarActions([ \Filament\Actions\BulkActionGroup::make([ DeleteBulkAction::make(), ]), ]); } public static function getPages(): array { return [ 'index' => Pages\ListMedications::route('/'), 'create' => Pages\CreateMedication::route('/create'), 'edit' => Pages\EditMedication::route('/{record}/edit'), ]; } }