Laravel-Backpack / community-forum

A workspace to discuss improvement and feature ideas, before they're actually implemented.
28 stars 0 forks source link

[Bug] Bulk restore not working #817

Closed mariusconstantin2503 closed 8 months ago

mariusconstantin2503 commented 8 months ago

Bug report

What I did

I enabled the trash operation adding the soft deletes on the model and the trait in the crud, as it is specified in the documentation. The trash and bulk trash are working but bulk restore not. I received an error "Call to undefined method Illuminate\Database\Eloquent\Builder::onlyTrashed()" It seems to come from here image

What I expected to happen

To successfully restore the items

What happened

An exception is shown

What I've already tried to fix it

yes

Is it a bug in the latest version of Backpack?

After I run composer update backpack/crud the bug... is it still there? yes

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is: image

karandatwani92 commented 8 months ago

Hey @mariusconstantin2503

I checked our demo, It's working there. https://demo.backpackforlaravel.com/admin/pet-shop/pet

For reference, you can check the demo's pet CRUD here: https://github.com/Laravel-Backpack/demo/blob/main/app/Http/Controllers/Admin/PetShop/PetCrudController.php

If this doesn't help, please share your CRUD controller to identify the issue.🤝

pxpm commented 8 months ago

It's probably missing to add SoftDeletes trait to the model. Also make sure you have the soft delete column in your database.

tabacitu commented 8 months ago

It's probably missing to add SoftDeletes trait to the model. Also make sure you have the soft delete column in your database.

Yup, sounds like that should be the problem.