I have this query below, I need to sort the Cars by a value that is collected from another table:
$cars = Car::paginate(100);
$cars->getCollection()->transform(function ($item) {
.....
....
...
$item['buy_date'] = Transaction::where('id', $item->buy_transaction)->first()->date;
});
I tried:
->sortBy('buy_date')
But it didn't sort the result.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire