1. I made a global scope for the article model to soft delete data
public static function boot()
{
parent::boot();
static::addGlobalScope("myPost",function(Builder $builder){
$builder->where("mark_status","<>",-1);
});
}
2. Then I reported the wrong No query results for model [App\ Post] when I operated on the soft deleted data.
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" => ""
];
}
do you have any good ways to solve it