Fan Fan - 17 days ago 5
PHP Question

How to array_values laravel collection?

I have a search result from

image
model and
$photo
saved the data which
$photo->type == 'photo'
.

$photo = $image->filter(function($photo,$key) use($path){
if($photo->type == 'photo'){
$photo->url = $path.$photo->image;
return $photo;
}
});


Here is the
$photo
collection and is there any way to
array_values()
the
items
data?

Collection {#352 ▼
#items: array:3 [▼
2 => ImageBanquet {#349 ▶}
3 => ImageBanquet {#350 ▶}
4 => ImageBanquet {#351 ▶}
]
}

Answer

Check values() collection helper.

$values = $collection->values();
Comments