Soft Deletes: Safely Removing Records
Learn how to hide records instead of permanently deleting them using soft deletes.
Mark Johnson
October 10, 2025
4.3k87
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