1、我对文章模型做了个全局scope用来软删除数据 public static function boot()
{ parent::boot(); static::addGlobalScope('myPost',function(Builder $builder){
$builder->where('mark_status','<>',-1);
});
}2、然后我在对这些软删除的数据进行操作的时候就报错了No query results for model [App\Post]. public function status(Post $post)
{ $this->validate(request(),[ 'status' => 'required|in:-1,0,1'
]);
$post->mark_status = request('status');
$post->save(); return [ 'error' => 0, 'msg' => ''
];
}大家有什么好的办法解决吗
添加回答
举报
0/150
提交
取消