Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ▶}
  ]
}
like image 901
Fan Avatar asked Nov 16 '16 07:11

Fan


1 Answers

Check values() collection helper.

$values = $collection->values();
like image 195
Alexey Mezenin Avatar answered Sep 28 '22 23:09

Alexey Mezenin