0
我尝试运行此查询,一切都很好,直到:两个查询子句,其中
- >其中( 'statut_licence_id',[ '1', '4'])
这第二个在哪里似乎不工作,它只显示我statut_licence_id = 1而不是4,现在有人如何解决这个问题?
$licencies = Licencies::whereIn('structure_id', $structures->pluck('id'))->whereIn('type_licence_id', ['1', '2', '3', '4', '5'])
->whereIn('statut_licence_id', ['1' , '4'])
->where('valid_licence_id', '1')
->where('lb_assurance_etat' ,'=' , 'Assurée')
->orderBy('created_at', 'DESC')
->paginate(10);
问题解决:
$licencies = Licencies::whereIn('structure_id', $structures->pluck('id'))->whereIn('type_licence_id', ['1', '2', '3', '4', '5']) ->where(function ($query) {
$query->whereIn('statut_licence_id', ['1' , '4'])
->where('valid_licence_id', '1'); })
->orderBy('created_at', 'DESC')
->paginate(10);
尝试打印原始查询。使用'DB :: enableQueryLog()'和'DB :: getQueryLog()' –
我应该在哪里? –
在查询之前放入'DB :: enableQueryLog()'。并在你的查询之后加入'var_dump(DB :: getQueryLog())''。 –