When getting multiple levels of data by using with() method in Laravel, sometimes you want to sort the collection by nested value. 

For example if we are getting events by user we will use query like this:

                    $events  = $event
   ->where('user_id','=',$id)
   ->with([
      'event'
   ])
   ->get();
                  

Assuming you already set DB foreign keys and Laravel models, this will return user with specific ID and all events connected to that user.

Now if we want to sort data by event date, we can do that on Laravel collection object:

                    $sorted_events = $events->sortBy(function ($event_sort) {
                return $event_sort->event->date;
            });
                  

We will get the data sorted by date in ASC order. If  we want to reverse the order, and get the data in DESC order we can just use ->reverse()

                    $sorted_events = $events->sortBy(function ($event_sort) {
                return $event_sort->event->date;
            })->reverse();
                  

And there you have it, your event list is sorted by date in DESC order.