schema([ Card::make() ->schema([ TextInput::make('name')->reactive() ->afterStateUpdated(fn ($state, callable $set) => $set('url', Str::slug($state))), TextInput::make('url'), RichEditor::make('description'), FileUpload::make('image') ->image()->imageCropAspectRatio('3:2') ->enableDownload()->directory('destination') ->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file): string { return (string) str($file->getClientOriginalName())->prepend(now()->timestamp); }), Select::make('location_id','')->relationship('location','name')->searchable()->options(Location::all()->pluck('name', 'id')), TextInput::make('price'), TextInput::make('time_period'), TextInput::make('rating'), 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); }), KeyValue::make('faqs')->reorderable() ->keyLabel('Question')->valueLabel('Answer') ->keyPlaceholder('Enter Question')->valuePlaceholder('Enter Answer') ]) ]); } public static function table(Table $table): Table { return $table ->columns([ TextColumn::make('name'), TextColumn::make('description')->wrap()->html()->limit(100), ImageColumn::make('image'), TextColumn::make('location'), TextColumn::make('price'), TextColumn::make('time_period'), TextColumn::make('rating'), ]) ->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); }*/ }), Tables\Actions\ForceDeleteAction::make(), Tables\Actions\RestoreAction::make(), ]) ->bulkActions([ Tables\Actions\DeleteBulkAction::make(), Tables\Actions\ForceDeleteBulkAction::make(), Tables\Actions\RestoreBulkAction::make(), ]); } public static function getPages(): array { return [ 'index' => Pages\ManageDestinations::route('/'), ]; } public static function getEloquentQuery(): Builder { return parent::getEloquentQuery() ->withoutGlobalScopes([ SoftDeletingScope::class, ]); } }