model中需use traits\model\SoftDelete; // 数据表中需添加一个 delete_time 字段保存删除时间 namespace app\index\model; use think\Model; use traits\model\SoftDelete; class User extends Model { use SoftDelete; protected static $deleteTime = 'delete_time'; // 5.2版本之前必须用stati…
软删除及其相关实现 在模型类中要使用SoftDeletestrait并设置$date属性数组 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; class Student extends Model { use SoftDeletes; //设置表名 public $table = 'students'; //设置主键…