I think the closure you get without actually changing some core files ...
- Request area ...
Areas of application make it easy to use query logic in your models. To define a scope, simply prefix a model method with a scope:
class News extends Eloquent { public function scopeStatus($query) { return $query->where('status', '=', 1); } }
Use of this area
$news = News::status()->get(); $news2 = News::status()->where('anotherColumn',2)->get();
This is not exactly what you wanted ... but its definitely a bit shorter than typing
News::where('status','=',1)->get();
again and again
source share