Combine Foreach Loop and Eloquent to perform a search | Laravel.io

PHOTO EMBED

Thu May 27 2021 03:40:17 GMT+0000 (UTC)

Saved by @mvieira

$query = Payment::query();
foreach ($input as $column => $values) {
    $query->whereIn($column, $values);
}
$zip = $query->first()->VendorZIP;
content_copyCOPY

https://laravel.io/forum/04-13-2015-combine-foreach-loop-and-eloquent-to-perform-a-search