On a collection, it should be possible to do
$collection->column('id');
to get the same result as what
array_column($array, 'id');
would give you.
Currently, I have had to go by using something like this:
$uuids = $collect->map(function($category) {
return $category->id;
});
Unless i'm missing something, there is no column method on collections?
Ah, it appears that pluck
does this.
Would it make sense to have an alias for pluck
as column
since thats what the method is called in PHP?
@shopblocks pluck makes perfect sense.
You are plucking id
column out of the array and creating a new one.
For anyone googling around
$collection->pluck('name')->toArray();
Most helpful comment
For anyone googling around
$collection->pluck('name')->toArray();