Method Illuminate\Database\Eloquent\Collection::lists does not exist
Method IlluminateDatabaseEloquentCollection::lists does not exist
In this session, we’ll try our hand at solving the "Method IlluminateDatabaseEloquentCollection::lists does not exist" puzzle by using the computer language.
Error Method Illuminate\Database\Eloquent\Collection::lists do not exist occurs when you call lists method on eloquent collection in Laravel version > 5.2. The lists() method has been deprecated from laravel version > 5.2. You can use the pluck method instead of the lists to get the same output.-
Get array of ids from users table using pluck() method
$userArrayIDs = User::get()->pluck('id'); dd($userArrayIDs);
Output :
Illuminate\Support\Collection Object ( [items:protected] => Array ( [0] => 4 [1] => 41 [2] => 75 [3] => 77 [4] => 78 [5] => 79
[6] => 80 [7] => 81 [8] => 82 [9] => 83 [10] => 84 ) )
You can get all the ids of the user's table in an array form using the pluck() method in laravel.
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
- Best code example for create order in Laravel for ecommerce
- How to pass link from controller to view in laravel on ajax call
- How to fill a column automatically while creating records in Laravel
- How to get the id of last record from collection object in laravel view
- Rename Pivot Table in Laravel
- How to disable timestamps in laravel
- Laravel 5.4 save data to database
- Laravel insert query not working
- Show old value while editing the form in Laravel
- Update record after find method in lavavel
- How to fetch single row data from database in laravel
- Split an Eloquent Collection by half in Laravel
- How to pass data to partial view file in laravel
- If condition in foreach loop in laravel
- How to send email in Laravel 11
- Retain selected value of select box in Laravel
- Get last record from table in laravel
- Get all users except the followings users in overtrue laravel-follow
- Laravel create multiple records in Pivot table
- How to Get records between two dates in Laravel
- Sample configuration files to create laravel project with docker using wsl (window subsystem linux)
- How to access the nth object from Laravel collection object ?
- How to generate .env file for laravel?
- How to insert dynamic value to additional column in pivot table in laravel
- How to get column names from table in Laravel