Whenever I add additional logic to Eloquent models, I end up having to make it a static
method (i.e. less than ideal) in order to call it from the model\'s facade.
My question is at more of a fundamental level such as why is all() accessible via the facade?
If you look at the Laravel Core - all() is actually a static function
public static function all($columns = array('*'))
You have two options:
public static function getAllSortedByMake()
{
return Car::where('....')->get();
}
or
public function scopeGetAllSortedByMake($query)
{
return $query->where('...')->get();
}
Both will allow you to do
Car::getAllSortedByMake();