'Laravel eloquent incremental sum (current + previous row)
I have a model (transactions) with this fields: ['ID', 'PRODUCT_ID', 'VALUE'] and I want to sum the current VALUE + the previous one in a RESULT (temporary field), e.g:
PRODUCT_ID VALUE RESULT
5by45y5 2 2
k7uu775 5 7
hhgf557 3 10
j457720 5 15
I'm trying to do it with Eloquent not query builder/raw query
Thank you in advance
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
