0
votes

laravel dev.

I have three tables let's say A, B, C

A
-----------
-id
-main_location_id // **main location entry = 1**

B
-----------
-id
-a_id
-allocated_qty

C
-----------    
-id
-a_id
-location_id // **main location enrty + other locations enrty- 1,2,3**
-total_qty
-aval_qty

Relation:

table A has many of B

table A also has many of C

Query:

A::with(['B'])
->with(['C']) // here I got all location object from C tables, but I only want main_location_id = location_id data object + its qty
->where('a.id', 1)
->first();

I don't understand how will I get location_id, total_qty, aval_qty from table C through table A

which has c.location_id = a.main_location_id

Even I don't know if I'm doing right?

is this possible?

please help me with this

Many thanks!