<?php
namespace app\portal\model;
use think\facade\Db;
use think\Model;
\\在模型引入
use think\model\concern\SoftDelete;
class CopTopicsModel extends Model
{
\\模型中使用
use SoftDelete;
protected $name = 'cop_topics';
protected $autoWriteTimestamp=true;
protected $deleteTime="delete_time";
public function user(){
return $this->belongsTo(User::class,"uid","id");
}
}
软删除时候delete_time默认是为NULL
使用Db::name(“xxxx”)->where($where)->delete()这样是不使用软删除,必须使用模型实例化才可以。