Individual Restore
The typical individual restore code will be as follows.
<?php Post::withTrashed()->find(1)->restore();
Multiple Restore
Instead of retrieving 1 row like the code above, by making use of "where()" clause, you can restore multiple rows at once.
<?php Post::withTrashed()->where('id', '>', 5)->restore();
Assuming you have 10 posts that have been soft deleted, running the code above will make the post from id 6 to 10 restored.
Leave a reply