schema([ Section::make('Destination Form') ->schema([ TextInput::make('name')->placeholder('Enter Destination Name')->reactive() ->afterStateUpdated(fn ($state, callable $set) => $set('url', Str::slug($state))), TextInput::make('url')->placeholder('URL of Destination Page'), Grid::make(1) ->schema([ RichEditor::make('description'), ]), FileUpload::make('image')->image() ->imageCropAspectRatio('16:9') ->enableDownload()->directory('destination') ->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file): string { return (string) str($file->getClientOriginalName())->prepend(now()->timestamp); }), FileUpload::make('destination_gallery')->multiple()->image() ->imageCropAspectRatio('16:9')->directory('destination_gallery') ->maxFiles(5)->enableDownload()->enableReordering() ->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file): string { return (string) str($file->getClientOriginalName())->prepend(now()->timestamp); }), Select::make('rating','')->searchable() ->options([ '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', ]), TextInput::make('price')->placeholder('Enter Price')->numeric(), TextInput::make('time_period')->placeholder('1 Day, 2 Day, etc'), Select::make('location_id','')->relationship('location','name')->searchable()->options(Location::all()->pluck('name', 'id')), Grid::make(1) ->schema([ KeyValue::make('faqs') ->keyLabel('Question')->valueLabel('Answer') ->keyPlaceholder('Enter Question')->valuePlaceholder('Enter Answer'), Textarea::make('meta')->placeholder('Enter Meta Data'), ]) ])->columns(2) ]); } public static function table(Table $table): Table { return $table ->columns([ TextColumn::make('name')->searchable(), ImageColumn::make('image'), TextColumn::make('location.name'), TextColumn::make('price'), TextColumn::make('time_period'), ]) ->filters([ // Tables\Filters\TrashedFilter::make(), ]) ->actions([ Tables\Actions\EditAction::make(), Tables\Actions\DeleteAction::make() ->after(function (Destination $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\ListDestinations::route('/'), 'create' => Pages\CreateDestination::route('/create'), 'edit' => Pages\EditDestination::route('/{record}/edit'), ]; } public static function getEloquentQuery(): Builder { return parent::getEloquentQuery() ->withoutGlobalScopes([ SoftDeletingScope::class, ]); } }