Q:

Laravel, multiple queries nesting with multiple order by

I am using Laravel 5.2. 
I have 3 tables (models):

Events
Dates
Sessions

My relations: Event hasMany Dates. Date hasMany Sessions.
The problem is that when i get the event with dates and session, the data are not ordered.
How can I get Event with ordered dates and every date with ordered sessions.
$event = Event::find($id);
$event->load(['dates' => function($query)
    {
        $query->orderBy('date', 'asc');
    }
]);

This is how i get an event with ordered dates. How to order sessions for every date?
Thanks

A:

I guess i've found the answer. The load didn't work inside the nested query. So i should use 'with' not 'load'.
$event = Event::find($id);
$event->load(['dates' => function($query)
            {   
                $query->with(['sessions' => function($query)
                                  {   
                                      $query->orderBy('starts_at', 'asc');
                                  }
                ])->orderBy('date', 'asc');
            }
    ]);

