foreach loop count laravel code example
Example 1: foreach in laravel
foreach ($users as $user) {
// stuff here
}
Example 2: laravel query foreach
$listing = Listing:where('id', $id);
foreach ($input as $key => $value) {
$i++;
// ->where('field_1', red_1); // Desired output
$listing->where("where(field_{$i},".$value."_1)");
}
$results = $listing->get();