
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
- Include External CSS and JS file in Laravel
- Call to a member function getRelationExistenceQuery() on array in Laravel
- Get last week data in Laravel
- Ajax GET request in laravel
- How to upload multiple images after preview in laravel using cropper js
- Update record after find method in lavavel
- How to add columns in existing table using migration in laravel
- How to get records in random order in laravel
- Laravel file size validation not working
- How to check if user has created any post or not in laravel
- Seed database using SQL file in Laravel
- Laravel delete all rows older than 30 days
- Eager loading dynamically in laravel
- How to get last month records in Laravel
- Redirect from www to non www in laravel using htaccess
- Laravel 9 route group with controller
- Get count of filter data, while return a small set of records
- How to get the id of last record from collection object in laravel view
- How to pass data to multiple partial view files in laravel
- Pass value from controller to model in laravel
- Property [user] does not exist on this collection instance
- Argument 1 passed to App\Http\Controllers\Auth\LoginController::authenticated() must be an instance of App\Http\Controllers\Auth\Request
- How to insert ckeditor data into database in Laravel?
- How to change default timestamp fields name in Laravel
- Laravel upload file with original file name