How to restore multiple records after soft-deletes in Laravel

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.

Answers 1
  • Restore multiple records after soft-deletes using where condition

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

    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

Related queries helps you to understand and may also used for implementation of current code snippet