0

我想在控制器中编写多个条件。我该如何解决这个问题?例如 :

$query = $query->where(function ($q,$request) { $q->where('product_name', 'like', '%'.$request->get('q').'%')->orWhere('product_id','like', '%'.$request->get('q').'%')->get();});

4

1 回答 1

0
 $result = User::where(function($query) use ($search) {
                $query->orWhere('product_name', 'LIKE', "%{$search}%")
                ->orWhere('product_id', 'LIKE', "%{$search}%");
            })->get();

I hope it would work for you.

于 2021-09-14T03:45:19.140 回答