controller - Laravel sum column in table -
i have 2 tables:
lectures id name 1 - lesson 1 2 - lesson 2 3 - lesson 3 lecturestype id id_lectures numb 1 - 1 - 10 2 - 2 - 20 3 - 1 - 30
how can sum numbs column each lesson , take result : name: lesson 1 numb: 40
i want display sum of numb each lesson.
try lecturestype::with('lectures')->sum('numb')->groupby('id_lectures')->get()
Comments
Post a Comment