Sort order laravel eloquent relation
00:57 29 May 2018

I facing the problem with sorting the laravel collection. I have created the query as follows.

 $schoolBookings = SchoolModel::with(['bookings.crts',
                        'bookings.crts.users' => function($que) {
                            $que->orderBy('first_name', 'ASC');
                        }
                        , 'schoolType',
                        'bookings.crts.teachingSpecializations',
                        'bookings' => function($que) use($filters, $input) {
                            if (!empty($input['start_date'])) {
                                $que->where('booked_on', '>=', $input['start_date']);
                            }
                            if (!empty($input['end_date'])) {
                                $que->where('booked_on', '<=', $input['end_date']);
                            }
                            $que->where('booked_on', '<=', date("Y-m-d 00:00:00"));
                            $que->orderBy('booked_on', 'desc');
                        },])
                    ->where(function($que) use ($filters) {
                        if (!empty($schoolId)) {
                            $que->where('id', $schoolId);
                        }
                    })
                    ->get()->toArray();

As you show sorting by booking working fine. But i want sorting according to booking date. Then by CRT user fisrt name here is out that i am getting.

Booking_date,  booking_id  USER_NAME    day
29/05/2018 -- 392514 --  Ehsanullah Islami Full day 
28/05/2018 -- 881393 --  Patricia Louden Full day 
28/05/2018 -- 848449 --  Ehsanullah Islami Full day
28/05/2018 -- 438674 --  Kirsten Wheeler Full day 
28/05/2018 -- 692704 --  Juliete Reim Full day
28/05/2018 -- 594508 --  Kasandra Kulas Full day 
28/05/2018 -- 737695 --  Roland Clements Full day 

Can anyone suggest how can sort order by booking that than CRT user name Alphabetically.

Thanks.

mysql laravel orm eloquent