1、我對(duì)文章模型做了個(gè)全局scope用來軟刪除數(shù)據(jù) public static function boot()
{ parent::boot(); static::addGlobalScope('myPost',function(Builder $builder){
$builder->where('mark_status','<>',-1);
});
}2、然后我在對(duì)這些軟刪除的數(shù)據(jù)進(jìn)行操作的時(shí)候就報(bào)錯(cuò)了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' => ''
];
}大家有什么好的辦法解決嗎
1 回答

慕標(biāo)5832272
TA貢獻(xiàn)1966條經(jīng)驗(yàn) 獲得超4個(gè)贊
我又將scope換成了軟刪除模型,然后在對(duì)軟刪除模型進(jìn)行恢復(fù)修改的時(shí)候也是報(bào)錯(cuò)No query results for model
添加回答
舉報(bào)
0/150
提交
取消