Laravel - Getting Started - Restoring Soft Deleted Models
Sometimes you may wish to "un-delete" a soft deleted model. To restore a soft deleted model, you may call the restore
method on a model instance. The restore
method will set the model's deleted_at
column to null
:
$flight->restore();
You may also use the restore
method in a query to restore multiple models. Again, like other "mass" operations, this will not dispatch any model events for the models that are restored:
Flight::withTrashed()
->where('airline_id', 1)
->restore();
The restore
method may also be used when building relationship queries:
$flight->history()->restore();