schema([ Section::make('Location Form') ->schema([ TextInput::make('name')->reactive() ->afterStateUpdated(fn ($state, callable $set) => $set('url', Str::slug($state))), TextInput::make('url'), FileUpload::make('image')->image() ->imageCropAspectRatio('16:9') ->enableDownload()->directory('location') ->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file): string { return (string) str($file->getClientOriginalName())->prepend(now()->timestamp); }), Select::make('category_id','')->relationship('category','name')->searchable()->options(Category::all()->pluck('name', 'id')), Select::make('rating','')->searchable() ->options([ '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', ]), ])->columns(2) ]); } public static function table(Table $table): Table { return $table ->columns([ TextColumn::make('name')->searchable(), ImageColumn::make('image'), TextColumn::make('category.name'), ]) ->filters([ // Tables\Filters\TrashedFilter::make(), ]) ->actions([ Tables\Actions\EditAction::make(), Tables\Actions\DeleteAction::make() ->after(function (Location $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\ListLocations::route('/'), 'create' => Pages\CreateLocation::route('/create'), 'edit' => Pages\EditLocation::route('/{record}/edit'), ]; } public static function getEloquentQuery(): Builder { return parent::getEloquentQuery() ->withoutGlobalScopes([ SoftDeletingScope::class, ]); } }