Reputation: 132
When I use restore method of soft delete it work`s well. But I want to do that multiple item restore at once time. Is it possible by soft delete? Any suggestion please. Thank you.
$products = Product::onlyTrashed()
->whereIn('id', $request->product_ids)
->get();
$products->restore();
Show the below error message.
Method Illuminate\Database\Eloquent\Collection::restore does not exist.
Upvotes: 1
Views: 1486
Reputation: 385
It is easy.
Just use restore() method on eloquent instead of collection:
$products = Product::onlyTrashed()
->whereIn('id', $request->product_id)
->restore();
Upvotes: 3