Level 4
Interesting question! Answere would be interesting too for me!
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 ??
Please or to participate in this conversation.