my question is about the possibilty of customizing Laravel's orderBy() method of the query builder, which i am using to sort an eager loaded dataset.
This is the query scope I am using to generate the dataset. Everything works fine so far with this.
 public function scopeRestaurantsWithMenusToday($query, $city_uri){
    return $query->where('city_uri', '=', $city_uri)->with([
        'restaurants',
        'restaurants.menusToday' => function($query) {
            $query->orderBy('date', 'asc');
        }
    ]);
}
What I want to achieve is an advanced 'asc' of the used orderBy() method in the eager load constraint of 'restaurants.menusToday':
- first all restaurants where "date == today"
 - then all restaurants where "date != today"
 
Can somebody help me out? Thx!
                        
Something like this may work... the idea is to add an additional select which is 0 or 1 depending on if the date is today. Then you can order by that column first, then the actual date second.