PHP code example of sbilyalov / yii2-softdelete

1. Go to this page and download the library: Download sbilyalov/yii2-softdelete 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/ */

    

sbilyalov / yii2-softdelete example snippets


use sbilyalov\yii2\behaviors\SoftDelete;

public function behaviors ()
{
    return [
        SoftDeleteBehavior::className()
    ];
}

use sbilyalov\yii2\behaviors\SoftDelete;
use yii\db\Expression;

public function behaviors ()
{
    return [
        [
            'class' => SoftDeleteBehavior::className(),
            'attribute' => 'deleted_time',
            'value' => new Expression('NOW()'),
            'restoreValue' => null
        ]
    ];
}

// soft delete model
$model->remove();

// delete soft-deleted model from database
$model->forceDelete();

// restore soft-deleted model
$model->restore();

// call SoftDelete::remove()
$model->delete();

php composer.phar