I would like to use orderBy in laravel but its not working while I have used CAST there
$this->adLists = ListingVisitor::with('listing')->selectRaw('CAST(sum(amount) as UNSIGNED) as total,listing_id,amount')->whereHas('listing.user',function($q){
$q->where('id',Auth::user()->id);
})->groupBy('listing_id')->orderBy('total','DESC')->paginate(10);
The result would be
136, 66, 1 ,5
Its actually should be 136, 66, 5, 1
I have using CAST in selectRaw but it has no difference