Tuesday, February 28, 2017

How to call scope in model?

I have the following method in model:

public function announcements()
    {
        return $this->categories()->with("announcements");
    }

And in the same model:

public function scopeActive($query)
    {
        return $query->where('votes', '>', 100);
    }

Hot to call this local scope in model for:

return $this->categories()->with("announcements")->active(); ?




via Darama

Advertisement