📜  带有可选过滤器的 laravel 查询 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:03.640000             🧑  作者: Mango

代码示例1
$cars = Car::when($request->get('make'), function ($query, $make) {
            $query->where('make', $make);
        })
        ->when($request->get('model'), function ($query, $model) {
            $query->where('model', $model);
        })