Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 搜索查询中的条件不为';行不通_Laravel - Fatal编程技术网

Laravel 搜索查询中的条件不为';行不通

Laravel 搜索查询中的条件不为';行不通,laravel,Laravel,我有一个搜索查询功能,它似乎无法处理最后一个条件。(->式中('structure_id','=',$mastructure) 事实上,当我运行查询时,我还从其他“structure\u id”获得了其他许可证 这是我的搜索控制器 public function getLicenciesStructure(Request $request){ $mastructure = Auth::user()->structure->id ; $search

我有一个搜索查询功能,它似乎无法处理最后一个条件。(->式中('structure_id','=',$mastructure)

事实上,当我运行查询时,我还从其他“structure\u id”获得了其他许可证

这是我的搜索控制器

 public function getLicenciesStructure(Request $request){

        $mastructure = Auth::user()->structure->id ;

        $search = $request->get('recherche');
        if ($search) {
            $query = Licencies::Where('lb_nom', 'like', "%$search%")->orWhere('num_licence' , 'like'  , "%$search%")->where('structure_id' , '=' , $mastructure);
        }

        $licenciestructures = $query->paginate(10)
            ->appends(['recherche' => $search]);

        return view('licencie_structure/index' , compact('licenciestructures' , 'mastructure'));


    }
有人知道为什么查询也会显示来自其他结构id的其他项吗?请提前多谢使用
where()
closure:

Licencies::where(function($q) use($search) {
    $q->where('lb_nom', 'like', '%'.$search'%')
      ->orWhere('num_licence', 'like', '%'.$search.'%');
})->where('structure_id', $mastructure);

谢谢你的回答!但是我的代码有一个错误!在第->行或者在哪里!也许引号有问题