digisin / yii2-softdelete
Soft delete behavior for Yii2.
Installs: 75
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 5
Type:yii2-behavior
Requires
- yiisoft/yii2: *
Requires (Dev)
- phpunit/dbunit: ~1.0
- phpunit/phpunit: ~4.0
- scrutinizer/ocular: ~1.1
This package is not auto-updated.
Last update: 2024-12-25 20:49:42 UTC
README
Soft delete behavior for Yii2.
Installation
The preferred way to install this extension is through composer.
Either run
$ composer require digisin/yii2-softdelete "*"
or add
"digisin/yii2-softdelete": "*"
to the require
section of your composer.json
file.
Usage
In your ActiveRecord class:
public function behaviors() { return [ \digisin\softdelete\SoftDeleteBehavior::className(), // or [ 'class' => \digisin\softdelete\SoftDeleteBehavior::className(), 'attribute' => 'deleted_time', 'value' => new \yii\db\Expression('NOW()'), // for sqlite use - new \yii\db\Expression("date('now')") ], ]; }
In your ActiveQuery class:
public function behaviors() { return [ \digisin\softdelete\SoftDeleteQueryBehavior::className(), // or [ 'class' => \digisin\softdelete\SoftDeleteQueryBehavior::className(), 'attribute' => 'deleted_time', ], ]; }