jeudi 9 juillet 2020

How to use order by query both with current table column and relationship table column in laravel?

i am trying to fetch record with order by query but situation is this that i have to use order by both on current table column and relationship table column in laravel . I tried this

 $consignments = Consignment::where('delivery_run_id', $id)->whereIn('status', [
            'In Warehouse',
            'With On Forwarder',
            'In Transit (Warehouse->Delivery)',
            'Awaiting Pickup'
        ])->with(['consignment_run_sheet' => function ($query) {
            $query->orderBy('run_sheet_id');
        }])->orderBy('delivery_date', 'DESC')->get();
        $deliveryRuns = DeliveryRun::all();

How I can achieve it?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire