'Laravel8 function to sum two columns from child rows and retrieve in parent table
Basically, I have these 3 columns, Total, totalachitat and another totalachitat. The Total column is from the database of the parent table (platis) and the other two are supposed to be from the child table (subplatis), I have this controller function but my problem is that it only displays one of the sums and not both.
$data = plati::select(DB::raw('platis.*,SUM(subplatis.totaleuro) as totaleuro'))
->select(DB::raw('platis.*,SUM(subplatis.totallei) as totallei'))
->leftJoin('subplatis','subplatis.plati_id','=','platis.id')
->groupBy('platis.id')
->get();
I am sorry for my broken english. If anyone knows how to help me I would gladly appreciate it
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

