Laravel - Diference between Model::lists('id') and Model::all()->lists('id')? -


in laravel 4, difference between 2 forms below make query using call lists?

example:

class user extends eloquent {}  user::all()->lists('id'); #first method  user::lists('id'); #second method 

the first method equates to

select * `users`; 

followed running below on collection.

array_pluck($this->items, $value, $key); 

the second method equates

select `id` `users`; 

both give array in values id column, latter retrieves relevant information database.

n.b. whilst question tagged laravel-4, worth noting has changed in 5.1 happen upon answer. lists in laravel >= 5.1 returns collection instance instead of plain array.


Comments