PHP code example of jrmadsen67 / laravel-cascade-updates

1. Go to this page and download the library: Download jrmadsen67/laravel-cascade-updates library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jrmadsen67 / laravel-cascade-updates example snippets




namespace App;

use App\Comment;
use jrmadsen67\Database\Support\CascadeUpdates;
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    use CascadeUpdates;

    protected $cascadeUpdates = ['comments' => ['is_active']];
    
    public function comments()
    {
        return $this->hasMany(Comment::class);
    }
}

$post = App\Post::find($postId)
$post->update(['is_active' => 0]); // Updates the post, which will also trigger the update() method on any comments and their children.