Laravel 搜索查询中的条件不为';行不通
我有一个搜索查询功能,它似乎无法处理最后一个条件。(->式中('structure_id','=',$mastructure) 事实上,当我运行查询时,我还从其他“structure\u id”获得了其他许可证 这是我的搜索控制器Laravel 搜索查询中的条件不为';行不通,laravel,Laravel,我有一个搜索查询功能,它似乎无法处理最后一个条件。(->式中('structure_id','=',$mastructure) 事实上,当我运行查询时,我还从其他“structure\u id”获得了其他许可证 这是我的搜索控制器 public function getLicenciesStructure(Request $request){ $mastructure = Auth::user()->structure->id ; $search
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);
谢谢你的回答!但是我的代码有一个错误!在第->行或者在哪里!也许引号有问题