schema([ Section::make('Service Form') ->schema([ TextInput::make('name')->placeholder('Enter Service Name')->reactive() ->afterStateUpdated(fn ($state, callable $set) => $set('url', Str::slug($state))), TextInput::make('url')->placeholder('URL of Service Page'), Grid::make(1) ->schema([ FileUpload::make('image')->image()->imageCropAspectRatio('16:9') ->enableDownload()->directory('service') ->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file): string { return (string) str($file->getClientOriginalName())->prepend(now()->timestamp); }), RichEditor::make('description')->placeholder('Enter Description'), ]), ])->columns(2) ]); } public static function table(Table $table): Table { return $table ->columns([ // ]) ->filters([ // Tables\Filters\TrashedFilter::make(), ]) ->actions([ Tables\Actions\EditAction::make(), Tables\Actions\DeleteAction::make() ->after(function (Service $record) { // delete single if ($record->image) { Storage::disk('public')->delete($record->image); } // delete multiple /*if ($record->galery) { foreach ($record->galery as $ph) Storage::disk('public/storage')->delete($ph); }*/ }), ]); } public static function getRelations(): array { return [ // ]; } public static function getPages(): array { return [ 'index' => Pages\ListServices::route('/'), 'create' => Pages\CreateService::route('/create'), 'edit' => Pages\EditService::route('/{record}/edit'), ]; } public static function getEloquentQuery(): Builder { return parent::getEloquentQuery() ->withoutGlobalScopes([ SoftDeletingScope::class, ]); } }