How to restore multiple records after soft-deletes in Laravel

Updated at 07-Jan-2022, By samar

How to restore multiple records after soft-deletes in Laravel

We’ll attempt to use programming in this lesson to solve the "How to restore multiple records after soft-deletes in Laravel" puzzle.

You can restore multiple records after soft-deletes in Laravel using restore() method. You can get all the specific records using where condition and use restore method to restore the deleted records.
  • Restore multiple records after soft-deletes using where condition

    App\Models\Post::onlyTrashed()->where('user_id', 1)->restore();
    

    It will restore all deleted records from the posts table where the value of column user_id equals to 1.

Back to code snippet queries related laravel