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

Rretzko's avatar
Level 15

Collection methods

Hi all - I'm designing a generic table that builds itself based on the attributes of a model. To do that, I'm leveraging the $model->getAttributes() method. When I try to research additional methods available to me, I'm hitting a blank page. For instance, when I search the Laravel documentation for getAttributes(), I get a 'no results' message. When I CTRL-B on PHPStorm, I get a 'Cannot find declaration to go to' message. When I Shift-Shift on PHPStorm I get hundreds of references. My question: Is there Laravel documentation available that defines the methods available to me for the Collection's metadata? Thanks!

0 likes
2 replies
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

Yes, there is Laravel documentation available that defines the methods available for Collections. You can find it here: https://laravel.com/docs/8.x/collections#available-methods

In addition to the methods listed in the documentation, you can also use any of the methods available on PHP's built-in array functions, as Collections extend PHP's array class.

To get a list of all available methods on a Collection instance, you can use the get_class_methods function. For example:

$collection = collect([1, 2, 3]);

$methods = get_class_methods($collection);

dd($methods);

This will output an array of all available methods on the Collection instance.

Rretzko's avatar
Level 15

Thanks @laryai . Just in case this can help someone else, do the following to get the alphabetical list of 291 methods:

//get methods
$methods = get_class_methods($object);
//put them in alpha-order
sort($methods);
//dump-and-die
dd($methods);

Please or to participate in this conversation.