
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
- Target class [App\Http\Controllers\Auth\Request] does not exist.
- How to upload multiple images after preview in laravel using cropper js
- SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
- How to call model in blade laravel
- Call to undefined relationship [user] on model [App\Models\Post]
- Root composer.json requires php ^7.3 but your php version (8.0.0) does not satisfy that requirement
- SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.post_id' in 'where clause
- Display option of select as selected with blade directive Laravel
- Route prefix with auth middleware in laravel
- Get id of last inserted record in laravel
- Conditional validation in laravel
- Remove array keys and values if it does not exist in other array in Laravel
- Call to undefined function Illuminate\Encryption\openssl_cipher_iv_length()
- How to get list of all views file in laravel
- Delete all related comments on deleting a post in Laravel
- How to check data inserted or deleted in pivot after toggle method
- Laravel pagination links with query string
- Convert input array to comma-separated string in laravel controller
- Validation for multiple forms on same page in laravel
- Show old value while editing the form in Laravel
- Delete records with relationship in laravel
- How to check email is valid or not in Laravel
- Ajax POST request in laravel
- Link storage folder in laravel 8
- How to update record after save method in Laravel