I have two method's in the User class that return different queries. I would like to use both like this
$users = User::fromCountry('DE')
->isMaster()
->paginate(20);
but it is not working, since isMaster() is a method from User and not from the query builder:
Call to undefined method Illuminate\Database\Query\Builder::isMaster()
I also tried
$users = User::fromCountry('DE')
->(User::isMaster())
->paginate(20);
but this is also not working. Is it possible to easily combine my queries from the User class?
Just in case its necessary, here are the two methods from the User class:
public static function isMaster()
{
switch (orga) {
case 1:
return static::where('modeIN','=','MT');
case 2:
return static::where('modeICI','=','CMT');
case 3:
return static::where('modeWHO','=','HMT');
}
}
public static function fromCountry($country)
{
return static::where(
function($query) use($country){
$query->whereHas('addresses',
function($q) use($country){
$q->where('idCountry','=',$country);
}
)
->orWhereHas('institutes',
function($q) use($country){
$q->whereHas('addresses',
function($q) use($country){
$q->where('idCountry','=',$country);
});
}
);
});
}