xxxxxxxxxx
$users = DB::table('users')
-> orderBy('name', 'desc')
-> get();
xxxxxxxxxx
// Make sure column names are correct
$inquiries = Inquiry::orderBy('status', 'ASC')
->orderBy('created_at', 'DESC')
->get();
xxxxxxxxxx
$inquiries = Inquiry::all()->sortByDesc('created_at')->sortByDesc('Status')->values();
xxxxxxxxxx
$models = Model::orderByRaw('FIELD(language, "USD", "EUR", "JPN")')->get();
// or
$models = Model::orderBy(DB::raw('FIELD(language, "USD", "EUR", "JPN")'))->get();
Model::query()
->whereIn('products.id', $idsCollection)
->orderByRaw('FIELD(products.id, '.$idsCollection->implode(',').')')
->select('products.*');