13

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 ▶}
  ]
}
Vijayanand Premnath
  • 3,415
  • 4
  • 25
  • 42
Fan
  • 1,124
  • 3
  • 17
  • 35
  • Possible duplicate of [Rearrange array index Eloquent Laravel](http://stackoverflow.com/questions/27309747/rearrange-array-index-eloquent-laravel) – patricus Nov 16 '16 at 07:51

1 Answers1

23

Check values() collection helper.

$values = $collection->values();
Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279