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
- How to pass query string to url in laravel
- Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found
- Target class [HomeController] does not exist
- How to create new user without form submission in laravel
- Pass value from controller to model in laravel
- How to send email in laravel
- Wheredate in laravel not working
- How to delete record in Laravel with ajax
- How to create project_user pivot table in laravel
- Route not defined in Laravel
- Show old value while editing the form in Laravel
- Get last record from table in laravel
- How to check column value of a record is null or not in laravel
- Laravel form request validation
- Add [name] to fillable property to allow mass assignment on [App\Models\Project]
- SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'posts_user_id_foreign'; check that column/key exists
- Laravel save object to database
- How to make Copy or Duplicate table row in laravel
- After image selected get validation error in laravel
- How to get IP address in laravel
- Get previous date data in laravel
- How to get route name on visit URL in laravel
- The POST method is not supported for this route. Supported methods: PUT.
- How to send ID to another page in Laravel
- Laravel csrf token mismatch for ajax POST Request