4
4
4sadly2021-01-10 15:12:43
Laravel
4sadly, 2021-01-10 15:12:43

How to calculate the amount of materials?

There are 3 tables
materials
material_orders
- material_id
- quantity
- order_type
- order_id
store_orders
- staff_id
- total
Like in a loop

foreach($materials as $material){

}

Can I find the number of materials? taking into account the fact that the staff_id of store_order is set by me (you can scope), but I don’t understand how to apply it.
You can do it in a simple way and find the sum of quantity material_order where store_order has staff_id = given

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lesnoyyy, 2021-01-14
@Lesnoyyy

If I understand correctly, you need to count the number of records in the table. Look here.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question