Large Datasets, Laravel, Sql, Eloquent, Optimization.
class Post extends Model { public function scopePublished($query) { return $query->where('published', true); } public function scopePopular($query) { return $query->where('views', '>', 1000); } } Now, you can use these scopes like so: $popularPosts = Post::published()->popular()->get(); Pretty