0
I’m starting at Laravel and I have doubts about eloquent
. Could someone help me convert that code SQL
in eloquent
?
SELECT COUNT(d.id) as total, d.nome_disciplina FROM bd_assuntos as a INNER
JOIN bd_disciplinas as d on d.id = a.id_disciplina GROUP BY d.id
$count_disciplina = DB::table('bd_assuntos as t')
->select('count() as total', 'd.nome_disciplina', 't.nome_assunto')
->join('bd_disciplinas as d', 't.id_disciplina', '=', 'd.id')
->orderBy('d.id') ->get();
Gleyson, welcome to Stackoverflow PT, please take a [tour] through the platform to understand how it works and how to formulate your questions.
– RFL
Please put in your post the code you’ve already tried to do and why it didn’t work, your question is looking more like a "do it for me" than a "do it for yourself," by the way, have you entered the Laravel documentation? https://laravel.com/docs/7.x/queries
– RFL
Yes, I’ve been in the documentation and several videos and courses, but this part has taken me seriously.
– Gleyson Moura
$count_disciplina = DB::table('bd_assuntos as t') ->select('Count() as total', ’d.discipline', ’t.subject_name') ->Join('bd_disciplinas as d', ’t.id_disciplina', '=', ’d.id') ->orderby(’d.id') ->get();
– Gleyson Moura