模型中使用,并且引入类
use traits\model\SoftDelete;
use SoftDelete;
控制器中
删除方法
public function delete($id){
BannerItem::destroy($id);
}
回收站方法
public function hsz(){
$res = BannerItem::onlyTrashed()->paginate(5);
$this->assign('res',$res);
return $this->fetch();
}
恢复删除方法
public function restore($id){
$restore =new BannerItem();
$restore->restore(['id' => $id]);
if (is_null($res)){
$this->error('恢复成功');
}
$this->success('恢复失败');
}
真实删除方法
public function deleteTrue($id){
BannerItem::destroy($id,true);
}
tp5.0中软删除使用和恢复
猜你喜欢
转载自blog.csdn.net/aa19891204/article/details/80958112
今日推荐
周排行