Answers for "laravel collection search"

PHP
0

get item from collection that match

$artist = 'Vincent John Doe';

// you can filter the collection and keep only those items
// that pass a given truth test:
$art_collection = $paintings->filter(function ($painting) use ($artist) {
  return $painting->artist == $artist;
});

// you can also do a foreach
foreach($paintings as $painting) {
  if($painting->artist == $artist) {
    $art_collection[] = $painting;
  }
}
Posted by: Guest on January-14-2021
0

laravel collection search

$collection = collect([2, 4, 6, 8]);

$collection->search(4);

// 1
Posted by: Guest on July-24-2021

Code answers related to "laravel collection search"

Browse Popular Code Answers by Language