
Method Illuminate\Database\Eloquent\Collection::lists does not exist
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.
Answers 1
-
Get array of ids from users table using pluck() method
$userArrayIDs = User::get()->pluck('id'); dd($userArrayIDs);
0Output :
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.
Random Code Snippet Queries: Laravel
- Insert dummy data in users table Laravel
- Multiple Level eager loading in Laravel
- Skip first n record and display rest records in laravel view
- Touch parent updated_at in Laravel
- Insert current date time in a column using Laravel
- Convert multidimensional array to single array in Laravel
- How to get user information using hootlex/laravel-friendships package in laravel
- How to fetch single row data from database in laravel
- Ajax POST request in laravel
- How to pass two variables in HREF in laravel
- How to get path from current URL in Laravel
- How to check if user has created any post or not in laravel
- Get ids in array from users table
- How to add class to tr in table using foreach in laravel
- How to insert multiple rows in mysql using loop in laravel?
- How to restore deleted records in laravel
- Trying to get property 'title' of non-object
- Retrieve count of nested relationship data in Laravel
- The Pusher library requires the PHP cURL module. Please ensure it is installed
- How to add active class to menu item in laravel
- SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.post_id' in 'where clause
- Create project factory and seed data in laravel
- SQLSTATE[42000]: Syntax error or access violation: 1055
- Call to undefined method Illuminate\Support\Facades\Request::all()
- Get domain name in laravel