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

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -