Laravel global scope cannot operate on restricted data after use.

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

Jul.23,2021

I replaced the scope with a soft delete model, and then reported an error No query results for model

when restoring and modifying the soft delete model.

clipboard.png

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eac69d-47eab.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eac69d-47eab.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?