PHP code example of zw / laravel-soft-delete-custom

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

    

zw / laravel-soft-delete-custom example snippets


composer 



namespace App\Models\Test;

use App\Models\BaseModel;
use ZW\Laravel\Eloquent\Custom\SoftDeletes;//注意 不用引用错

class TestModel extends BaseModel
{
    use SoftDeletes;//使用软删除trait
    
    protected $table = 'test';

    const DELETED = 'is_deleted';//软删除字段 不设置默认为is_deleted
    const DELETED_VALUE = 1;//软删除值 不设置默认为1
    const UN_DELETED_VALUE = 0;//未删除值 不设置默认为o
    
    
    //如果是比较发杂的删除值 可以在模型中覆盖 trait中分方法getDeletedValue()、getUnDeletedValue()
//    public function getDeletedValue()
//    {
//        return time();
//    }    


}