Laravel Soft Deletes: Safe Data Removal
January 16, 2026
•
1 min read
•
45 views
Table of Contents
Safe deletion with soft deletes:
Enable Soft Deletes
use SoftDeletes;
protected $dates = ['deleted_at'];
Migration
$table->softDeletes();
Query Soft Deleted
$trashedPosts = Post::onlyTrashed()->get();
$allPosts = Post::withTrashed()->get();
Restore and Force Delete
$post->restore();
$post->forceDelete();
Related Posts
Laravel Sanctum API Authentication Complete Guide
Build secure API authentication with Laravel Sanctum for SPAs and mobile apps.
Laravel Rate Limiting: Protect Your Application
Implement rate limiting to protect your Laravel application from abuse.
Laravel Blade Components: Build Reusable UI
Create powerful reusable components with Laravel Blade.
Comments (0)
No comments yet. Be the first to comment!