farshadf's avatar

Custom Sorting by Nested Relationship spatie Querybuilder

i am writing a custom sort to sort my model by its relationship but the problem is that i want to sort my models by the relations of that relation which means the nested relationship i am using spatie query builder package. so if i have this now :

            ->allowedSorts([AllowedSort::custom('hits', new PriceSort(),'hits'),

and in my PriceSort

 $direction = $descending ? 'DESC' : 'ASC';
        return $query->with('accommodationRooms.roomPricingHistorySearch')
        ->orderByRaw("(`{$property}`) {$direction}");

here now i want to sort the $query which is my hotel Model by one of the roomPricingHistorySearch fields . how can i achive that ??

0 likes
2 replies
MUM's avatar

Interesting question! Answere would be interesting too for me!

farshadf's avatar

thanks to you for your attention i would really like to solve it .

Please or to participate in this conversation.