
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
- Argument 1 passed to App\Http\Controllers\Auth\LoginController::authenticated() must be an instance of App\Http\Controllers\Auth\Request
- Argument 1 passed to Symfony\Component\HttpFoundation\Response::setContent() must be of the type string or null, object given
- Undefined property: stdClass::$title
- How to make Copy or Duplicate table row in laravel
- If no route matched route::fallback in laravel
- Laravel insert query not working
- Connection could not be established with host smtp.gmail.com :stream_socket_client(): unable to connect to tcp://smtp.gmail.com:587 (Connection refused)"
- Wheredate in laravel not working
- How to upload image in laravel 8
- Show old value while editing the form in Laravel
- Insert current date time in a column using Laravel
- Display option of select as selected with blade directive Laravel
- Add [name] to fillable property to allow mass assignment on [App\Models\Project]
- How to get query string value in laravel
- Laravel route redirect not working
- Recursive function example code PHP Laravel
- How to get session in blade Laravel ?
- Laravel 9 pagination with search filter
- Class 'App\Http\Controllers\User' not found
- Call to undefined function Illuminate\Encryption\openssl_cipher_iv_length()
- How to get count of all records created at yesterday
- How to call controller function from view in Laravel
- Update last created record in Laravel
- Laravel migration add foreign key to existing table
- How to add columns in existing table using migration in laravel