laravel eloquent all order by code example
Example 1: laravel order by desc
$posts = Post::orderBy('id', 'DESC')->get();
Example 2: laravel order by
$users = DB::table('users')
-> orderBy('name', 'desc')
-> get();
Example 3: laravel eloquent order by alphabetical order
$items = Item::orderBy('name')->get();
Example 4: laravel create model
php artisan make:model Flight
php artisan make:model Flight --migration
php artisan make:model Flight -m
Example 5: laravel get all records order by
$posts = Post::orderBy('created_at', 'desc')->get();
Example 6: laravel get all records order by
$results = Project::orderBy('name')->get();