You probably have to use joins (and alter this code based on your table, etc.).
$lectures = Lecture::join('lectures_types', 'lectures_types.id_lectures', '=', 'lectures.id')
->selectRaw('lectures.*, SUM(lectures_types.numb) as total')
->groupBy('lectures.id')
->get();
there is another neat trick where you create a relationship.. google it.. and then you can do
ModelONE::with(count)->get();
...
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community