There is no method for that at the moment, you can find all available methods in the documentation
Documentation: http://laravel.com/docs/5.1/collections#available-methods
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, I am wondering if there is some method to use on Collections, similar to:
$request->only(['some', 'keys', 'to', 'get']);
Sometimes I have a collection containing many keys which I don't need to get, and I would like some fast way to get the ones I need. I know I can specify them manually, but this would be faster. For now I made a helper:
function collectionGetArray(Collection $collection, $keys) {
$output = array();
foreach ($keys as $key) {
$output[$key] = $collection->get($key);
}
return $output;
}
But I would like to know if I am missing some official way.
Thank you.
There is no method for that at the moment, you can find all available methods in the documentation
Documentation: http://laravel.com/docs/5.1/collections#available-methods
Please or to participate in this conversation.