Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在控制器中编写多个条件。我该如何解决这个问题?例如 :
$query = $query->where(function ($q,$request) { $q->where('product_name', 'like', '%'.$request->get('q').'%')->orWhere('product_id','like', '%'.$request->get('q').'%')->get();});
$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.