
How to show data by ID in laravel?
How to show data by ID in laravel?
In this article, we will see how to solve "How to show data by ID in laravel?".
You can display data in view file using by id in ASC and DESC order in laravel-
Display data orderby id DESC in laravel
$posts = Post::orderBy('id', 'DESC')->get();
You can display data in DESC order (3, 2, 1) largest to smallest in laravel view using the orderby() method. The post with id 3 will be on top and after that 2 and 1 will be shown.
-
Display data orderby id ASC in laravel
$posts = Post::orderBy('id', 'ASC')->get();
You can display data in ASC order (1, 2, 3) smallest to largest in laravel view using the orderby() method. The post with id 1 will be on top and after that 2 and 3 will be shown.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- How to get id of next record in laravel
- File_put_contents(/var/www/html/w3code/storage/framework/sessions/CXwN3EXKxERD6jgy3rADcaAAbAx8FRKih2JK7UO9): Failed to open stream: Permission denied
- How to add unique records in pivot columns of Laravel pivot table
- Laravel order by date not working
- Class "App\Http\Controllers\Auth\Verified" not found
- Use withCount() to get total number of records with relationship
- Symlink(): No such file or directory
- How to pass link from controller to view in laravel on ajax call
- How to get user information using hootlex/laravel-friendships package in laravel
- Automatically remove records using Prunable trait in Laravel
- Print query in laravel
- How to disable timestamps in laravel
- Remove public from url in laravel project
- How to create laravel project using composer
- How to add class to tr in table using foreach in laravel
- How to use more than one query scope in Laravel
- Display data in table using foreach in Laravel
- How to get all route list
- How to check find method executed successfully in laravel
- Ajax GET request in laravel
- Class 'App\Http\Controllers\User' not found
- Create project table with model and migration
- How to make Copy or Duplicate table row in laravel
- How to get column names from table in Laravel
- Call to undefined method Illuminate\Support\Facades\Request::all()