How to sort by a json column with the relationship in laravel; My code:
$query = DispatchStatus::query();
$query->has("order");
$column = "name";
$sortBy = "desc";
$query->with("order", function ($subQuery) use ($column, $sortBy) {
info($column . "__" . $sortBy);
$subQuery->orderBy('recipient->' . $column, $sortBy);
});
$results = $query->paginate();
I got the unsorted results! How can I sort by the recipient name in the JSON column?