在`laravel`中查询数据库时
有时间查询条件稍微复杂
这个时候我们可以使用`闭包函数`
```
1 $data = Test::where(function ($query) use ($request) {
2 $id = $request->input('id');
3 $name = $request->input('name');
4 $query->where('id', 'like', '%' . $id . '%')->where('value', 'like', '%' . $name . '%');
5 })->get()->toArray();
6 dump($data);
7 $data = Test::where(function ($query) use ($request) {
8 $name =!empty($request->get('name'))?$request->get('name'):'';
9 $id =!empty($request->get('id'))?$request->get('id'):'';
10 $ide =!empty($request->get('ide'))?$request->get('ide'):'';
11 $query->where('value', 'like', '%' . $name . '%');
12 if ($id!=$ide){
13 $query->whereBetween('id',[$id,$ide] );
14 }
15 })->get()->toArray();
16 dump($data);
```