How would I create a scope that can be used by multiple models without polluting the global scope space? This scope would be manually called each time I want to use it.
Example:
$assigns = Assign::dryScope();
$contacts = Contact::dryScope();
How would I create a scope that can be used by multiple models without polluting the global scope space? This scope would be manually called each time I want to use it.
Example:
$assigns = Assign::dryScope();
$contacts = Contact::dryScope();
Best way is to use traits. Use appropriate namespacing as needed. ScopeTrait.php
trait ScopeTrait {
protected function dryScope() {
//Scope definition
}
}
class Assign extends xModel
{
use ScopeTrait;
}