PHP code example of liuyuanjun / yii2-softdelete
1. Go to this page and download the library: Download liuyuanjun/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/ */
liuyuanjun / yii2-softdelete example snippets
use liuyuanjun\yii2\softdelete\SoftDeleteTrait;
/*
⚠️ 注意 Attention:
数据表主键类型只能为 int 或者 string !'is_deleted'字段类型与主键相同且默认值设置为 0 或 空字符串。
*/
class Model extends \Yii\db\ActiveRecord
{
use SoftDeleteTrait;
/**
* is_deleted column name
* The default value is 'is_deleted', if you want to change it overwrite this method.
* @return string
* @author Yuanjun.Liu <[email protected]>
*/
public static function getIsDeletedAttribute(): string
{
return 'is_deleted';
}
}
//+++++ OR +++++
class Model2 extends \liuyuanjun\yii2\softdelete\SoftDeleteActiveRecord
{
public static function getIsDeletedAttribute(): string
{
return 'is_deleted';
}
}