i get stuck here. Hope someone can help. i have a database that store the purchase done users on any project.
here is my table in twig
<tbody>
{% for paid_log in paid_logs %}
{% paid_log.user_id == user.id and paid_log.status == 2 %}
<tr>
<td>{{paid_log.project.name }}</td>
<td>{{paid_log.amount }}</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
Results
|Project ID| Purchase Amount|
1 |1000
1 |1010
2 |2111
4 |9954
1 |9871
4 |6121
I want to loop through the database and sum up the purchase amount where the project ID is the same?
Expecting something like this:
Project ID |Purchase Total
1 |11881
2 |2111
4 |16075