Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

opheliadesign's avatar

->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') :
0 likes
10 replies
fujoprof's avatar

Thanks guys! I Am using laravel 8, and pluck is working for me.

opheliadesign's avatar

Thanks guys! Odd that PHPStorm just decided to list it as deprecated. Oh well. :)

RoboRobok's avatar

Deprecated doesn't mean deleted. It means deprecated.

2 likes
Dan's avatar

@opheliadesign PHPStorm picks up on the following docblock:

@deprecated since version 5.2. Use the "pluck" method directly. 

from Illuminate\Support\Collection.php

1 like
Naj's avatar

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 ?

Ace's avatar

$roles = Role::get()->pluck('display_name');

Please or to participate in this conversation.