2
I need to execute a query with the parameters as below:
$questoes = Questao::leftJoin('capitulos_questoes', 'capitulos_questoes.questoes_id', '=', 'questoes.id')
->leftJoin('modulos_questoes', 'modulos_questoes.questoes_id', '=', 'questoes.id')
->leftJoin('banco_disciplinas', function($join){
$join->on('banco_disciplinas.id', '=', 'capitulos_questoes.banco_disciplinas_id')
->orOn('banco_disciplinas.id', '=', 'modulos_questoes.banco_disciplinas_id');
})
->leftJoin('banco_series', function($join){
$join->on('banco_series.id', '=', 'capitulos_questoes.banco_series_id')
->orOn('banco_series.id', '=', 'modulos_questoes.banco_series_id');
})
->whereIn('avaliada', $status)
->whereIn('tipo', $tipo)
->whereIn(function ($query) use ($serie){
$query->whereIn('modulos_questoes.banco_series_id',$serie)
->orWhereIn('capitulos_questoes.banco_series_id', $serie);
})
->whereIn(function ($query)use ($disciplina){
$query->whereIn('modulos_questoes.banco_disciplinas_id', $disciplina)
->orWhereIn('capitulos_questoes.banco_disciplinas_id', $disciplina);
})
->select('questoes.id as id', 'questao', 'serie', 'ensino', 'avaliada', 'disciplina', \DB::raw('DATE_FORMAT(questoes.created_at, "%d/%m/%Y") as data'))
->paginate($pag);
I’m having difficulties with the anonymous whereIn
. If I take the part below, the query works:
->whereIn(function ($query) use ($serie){
$query->whereIn('modulos_questoes.banco_series_id',$serie)
->orWhereIn('capitulos_questoes.banco_series_id', $serie);
})
->whereIn(function ($query)use ($disciplina){
$query->whereIn('modulos_questoes.banco_disciplinas_id', $disciplina)
->orWhereIn('capitulos_questoes.banco_disciplinas_id', $disciplina);
})
The query is returning this error:
Missing argument 2 for
Illuminate\Database\Query\Builder::WhereIn()
I don’t know how to do with these whereIn
to work.
Amanda instead of "photos" copy and paste the error, it is easier.
– Guilherme Nascimento
Note: I withdrew the closing vote, because the confusion between Where and wherein is not really a "mistake", but goes from the understanding of the framework, what seems to me a valid doubt. BS 2: It wasn’t me who was negative.
– Guilherme Nascimento
I find the doubt valid equal quote @Guilhermenascimento... also I was not the one who negatived.
– novic
Although I think the question is a typo, I was not the one who denied it as well. In this case, if someone disagrees with the scope of the question, they should use the closing options. Voting is another case.
– Wallace Maxters