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

Popular posts from this blog

html - Difficulties with background-image property -

visual studio code - What does the isShellCommand property actually do and how should you use it? -

ios - Segue not passing data between ViewControllers -