Global scope model

Submitted by GesJeremie - 5 years ago

Sometimes you must always use a global scope when you perform a query from your model.


class Comment extends Eloquent {

	public function newQuery()
		return parent::newQuery()->where('cat', '=', 6);
    // Now when you will perform a query like :
    // Comment::count()
    // Your scope defined in the newQuery will be used