Home API Tools Posts Hire Me About
Sign In Create Account
Laravel

Laravel Soft Deletes: Safe Data Removal

January 16, 2026 1 min read 45 views

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();
Share this post:

Related Posts

Comments (0)

Please log in to leave a comment. Log in

No comments yet. Be the first to comment!