PHP code example of touhidurabir / laravel-model-soft-cascade

1. Go to this page and download the library: Download touhidurabir/laravel-model-soft-cascade 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/ */

    

touhidurabir / laravel-model-soft-cascade example snippets


class User extends Model {

    use SoftDeletes;

    use HasSoftCascade;

    public function cascadable() : array {

        return [
            'profile', 'posts'
        ];
    }

    public function profile() {

        return $this->hasOne('Touhidurabir\ModelSoftCascade\Tests\App\Profile');
    }

    public function posts() {

        return $this->hasMany('Touhidurabir\ModelSoftCascade\Tests\App\Post');
    }
}

/**
 * The cascade custom configurations
 *
 * @return array
 */
public function cascadable() : array  {

    return [
        'delete' => [
            'enable'    => true,
            'event'     => 'deleted',
            'relations' => [...],
            'force'     => true,
        ],
        'restore' => [
            'enable'    => true,
            'event'     => 'restored',
            'relations' => ['comments'],
        ]
    ];
}

/**
 * The cascade custom configurations
 *
 * @return array
 */
public function cascadable() : array  {

    return [
        'delete' => [
            'enable'    => true,
            'event'     => 'deleted',
            'relations' => [...],
            'force'     => true,
        ]
    ];
}
bash
php artisan vendor:publish --provider="Touhidurabir\ModelSoftCascade\ModelSoftCascadeServiceProvider" --tag=config