I am trying to sort a query (to a postgresql database) in laravel so that nulls are last.
The code for the order by is
$dbObj->orderBy($aSearchFilters["sidx"],$aSearchFilters["sord"]);
I found How to sort NULL values last using Eloquent in Laravel but all of these have a fixed column that is being sorted on. Is their a way of getting NULLS LAST added to the order by without introducing sql injection issues?
DB::raw()
solve your concern? See stackoverflow.com/questions/23326695/… – PaePaeorderByRaw
. Its second parameter is bindings, so it is injection-protected. – shukshin.ivan