-
ensure that the first row has all the keys you want
-
you can search with the example below
$items = $collection->where('foo', 'bar');
$items->all();
- this will return all the items where 'foo' had the value 'bar'
<?php | |
$headers = array(); | |
$raw_data = array(); | |
foreach($client[0] as $pos=>$row){ | |
if($pos === 0){ | |
//get keys | |
$headers = $row; | |
}else{ | |
// dd($row, $headers); | |
$item = array(); | |
foreach($headers as $key=>$val){ | |
$item[$val] = $row[$key]; | |
} | |
array_push($raw_data, $item); | |
} | |
} | |
$collection = collect($raw_data); | |
return $collection; | |
?> |