Soft Deletes: Safely Removing Records
Learn how to hide records instead of permanently deleting them using soft deletes.
Mark Johnson
Oct 11, 2025
21k525
Soft deletes mark records as deleted without removing them from the database.
## Enable soft deletes
Migration:
```php
$table->softDeletes();
```
Model:
```php
use Illuminate\Database\Eloquent\SoftDeletes;
class Post extends Model {
use SoftDeletes;
}
```
## Use
```php
$post->delete();
Post::withTrashed()->find(1)->restore();
```
## Flow
```mermaid
flowchart LR
A[delete()] --> B[deleted_at set]
B --> C[Hidden]
D[restore()] --> E[Visible again]
```
Soft deletes are useful for recovery and audit safety.
In the next tutorial, we will move validation into form request classes.
#Laravel#Database#Intermediate