I have this query:
select
Q.id,Q.questao,
D.disciplina,
S.serie,
S.ensino
from questoes as Q
left join capitulos_questoes as CQ
on CQ.questoes_id = Q.id
left join modulos_questoes as MQ
on MQ.questoes_id = Q.id
left join banco_disciplinas as D
on (D.id = CQ.banco_disciplinas_id) or (D.id = MQ.banco_disciplinas_id)
left join banco_series as S
on (S.id = CQ.banco_series_id) or (S.id = MQ.banco_series_id)
I need to page the results of this query in Laravel 5.2. I'm having trouble consulting with Eloquent because I'm using or
in LEFT JOIN
.
I tried to do this:
$questoes=\DB::select('select Q.id,Q.questao, D.disciplina, S.serie, S.ensino
from questoes as Q
left join capitulos_questoes as CQ
on CQ.questoes_id = Q.id
left join modulos_questoes as MQ
on MQ.questoes_id = Q.id
LEFT join banco_disciplinas as D
on (D.id = CQ.banco_disciplinas_id) or (D.id = MQ.banco_disciplinas_id)
left join banco_series as S
on (S.id = CQ.banco_series_id) or (S.id = MQ.banco_series_id)')
->paginate(15);
but returns an error saying that it is not possible to paginate an array. How can I resolve?