Scopes
Scope provides elegant way to write commonly used query fragments and improve readability of your code. Scope returns a new collection Collection or taint the current Collection.
Let's get an example:
Scope can be easily chained and you can pass argument to them too:
Scope live both in Model::Collection
and Model
code space, meaning you may ignore Model.query
to start a new Collection but instead go straight to Model.scope
.
Last updated