Video
Description
Cascading soft deletes for the Laravel PHP Framework.
<?php namespace App; use App\Comment;use Dyrynda\Database\Support\CascadeSoftDeletes;use Illuminate\Database\Eloquent\Model;use Illuminate\Database\Eloquent\SoftDeletes; class Post extends Model{ use SoftDeletes, CascadeSoftDeletes; protected $cascadeDeletes = ['comments']; protected $dates = ['deleted_at']; protected $fetchMethod = 'get'; // get, cursor, lazy or chunk // protected $chunkSize = 500; public function comments() { return $this->hasMany(Comment::class); }}
Now you can delete an App\Post record, and any associated App\Comment records will be deleted. If the App\Comment record implements the CascadeSoftDeletes trait as well, it's children will also be deleted and so on.
$post = App\Post::find($postId)$post->delete(); // Soft delete the post, which will also trigger the delete() method on any comments and their children.
Related Content on Laravel Daily
Video
Video
Video
Recent Courses on Laravel Daily
AI Agents/IDEs for Laravel: May 2026 (Claude Code, Codex, OpenCode, etc)
7 lessons
52 min
Next.js Basics for Laravel Developers
11 lessons
58 min
How to Structure Laravel 13 Projects
16 lessons
1 h 32 min read