
How to get the id of last record from collection object in laravel view
You can get the id of the last record from the collection object using the last() method in your view file. You can call the last() method with no arguments to get the last element in the collection.
Answers 2
-
Get id of last record from collection object in laravel view
//routes\web.php Route::get('/get-id-of-last-record', function(){ $posts = App\Models\Post::get(); return view('index')->with(compact('posts')); }); //resources\views\index.blade.php {{ $posts->last()->id }}
0 -
Get id of last record from collection object in laravel
//routes\web.php Route::get('/get-id-of-last-record', function(){ $posts = App\Models\Post::get(); return $posts->last()->id; });
0
Random Code Snippet Queries: Laravel
- Laravel hasmany select not working
- Target class [HomeController] does not exist
- How to fill a column automatically while creating records in Laravel
- How to customize pagination view in laravel
- How to implement toggleLike() method in Overtrue\LaravelLike laravel package
- How to pass external link in laravel blade to anchor tag
- Conditional where clause in Laravel
- Laravel 9 pagination with search filter
- How to pass link from controller to view in laravel on ajax call
- How to return error message from controller to view in laravel
- Route group with URI prefix using middleware and route name prefixes
- First and last item of the array using foreach iteration in laravel blade
- How to use or operator in laravel
- How to validate URL with https using regex in laravel
- How to insert ckeditor data into database in Laravel?
- Delete file from amazon s3 bucket using Laravel
- Send post data from controller to view
- How to create and run user seeder in laravel
- Store logged in user details in session and display in view in laravel
- Get last record from table in laravel
- RuntimeException You must enable the openssl extension in your php.ini to load information from https://repo.packagist.org
- Illuminate\Database\QueryException could not find driver
- Credit card validation in laravel
- Laravel 9 route group with controller
- Get count of filter data, while return a small set of records