->lists() deprecated? Replacement? Hi everyone,
I noticed this morning that the collection method ->lists() is deprecated. I have been looking around for information on what replaced this without much luck.
Example:
User::smsRecipients()->lists('phone_cell') :
It has been renamed to pluck
https://laravel.com/docs/5.2/upgrade#upgrade-5.2.0
Scroll to the "Deprecations" section :)
The lists method on the Collection, query builder and Eloquent query builder objects has been renamed to pluck. The method signature remains the same.
Thanks guys! I Am using laravel 8, and pluck is working for me.
Thanks guys! Odd that PHPStorm just decided to list it as deprecated. Oh well. :)
I can still use it on laravel 5.2
How it is deprecated?
Deprecated doesn't mean deleted. It means deprecated.
@opheliadesign PHPStorm picks up on the following docblock:
@deprecated since version 5.2. Use the "pluck" method directly.
from Illuminate\Support\Collection.php
I just found out that lists is deprecated and replaced by pluck. But, I don't know how to use the new method here :
$roles = Role::pluck('display_name','id');
$userRole = $user->roles->lists('id','id')->toArray();
Can anyone help me here please ?
$roles = Role::get()->pluck('display_name');
Please sign in or create an account to participate in this conversation.