laravel order by desc
snippet in php

order By Asc in laravbel

user508

->orderBy('id', 'DESC');

eloquent model sort by ascending order

user7102

$posts = Post::orderBy('id', 'DESC')->get();

orderby in laravel

user5766

/**
 * Show the application dashboard.
 *
 * @return \Illuminate\Http\Response
 */
public function index()
{
    $messages = Message::select("*")
                            ->where('receiver_id',$id)
                            ->orderBy('created_at', 'desc')
                            ->get();
  
    dd($messages);
}

laravel order by raw

user5391

$orders = DB::table('orders')
                ->orderByRaw('updated_at - created_at DESC')
                ->get();

laravel order by desc

user721

$posts = Post::orderBy('id', 'DESC')->get();