Is it possible to do orderBy()
or
orderBy()
in Laravel Eloquent? My current query only sorts the item.ItemID
upon user clicking sort on the frontend but it won't sort item.Desc
when the user clicks sort on the frontend.
I've tried putting these orderBy()
s inside of a where()
clause using a closure but that didn't work either. Does anyone know of a good way I could rectify this?
$this->model
->join('awards', 'item.ItemID', '=', 'awards.LinkID')
->join('opportunities', 'awards.AwardID', '=', 'branch.AwardID')
->groupBy('item.ItemID', 'item.Desc')
->orderBy('item.ItemID', $clickedDInventoryItemIdFlag ? 'DESC' : 'ASC')
->orderBy('item.Desc', $clickedDescriptionColumnFlag ? 'DESC' : 'ASC')
->select("item.ItemID", "item.Desc", "branch.OppID")
->get();