I have 4 tables:
Table_A
- id
- sth
Table_B
- id
- a_id
- sth
Table_C
- id
- b_id
- sth
Table_D
- id
- c_id
- sth
The relationships are as followed
Table_A <- Table_B (One to Many)
Table_B <- Table_C (One to Many)
Table_C <- Table_D (One to Many)
In order to access Table_C
and Table_D
from Table_A
I used a hasManyThrough
relationship for C
and D
. So now I pass a_id
, b_id
and c_id
on GET because and I want to check if the relation between them exists.
First I tried this:
Table_A::with('Table_B.Table_C.Table_D')
The problem is I don't know how I can pass ids for each of the tables and I'm not sure if it will work, I would like to know if this can work or if there is a better way to check these relationships exist.