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 ▶}
  ]
}
1

1 Answer 1

23

Check values() collection helper.

$values = $collection->values();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.