PHP code example of ereminmdev / yii2-deleted

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

    

ereminmdev / yii2-deleted example snippets


public function behaviors()
    {
        return [
            [
                'class' => DeletedBehavior::class,
                'comment' => function (self $model, DeletedBehavior $behavior) {
                    return 'Модель «' . $model->title . '»';
                },
            ],
        ];
    }

public function actions()
{
    return [
        'deleted-restore' => [
            'class' => 'ereminmdev\yii2\deleted\RestoreAction',
        ],
    ];
}

echo Url::toRoute(['/site/deleted-restore', 'id'=>MODEL_ID]);

$query = Deleted::find()->andWhere(['<', 'created_at', strtotime('-1 month')]);
foreach ($query->each() as $model) $model->delete();