I am using Laravel 5.3. I have 4 tables. The default table is Users
. Departments
, Position
, Employees
.
Users
table has ID | Email | Password
ID | Email | Password
Departments
table has an ID | Department | User_Id
ID | Department | User_Id
ID | Department | User_Id
- here User_Id
is the foreign key coming from the Users
table ID
Positions
table has an ID | Position | Department_Id
ID | Position | Department_Id
ID | Position | Department_Id
- here Department_Id
is the foreign key from the Departments
table ID
Employees
table has an ID | Employee | Position_Id
ID | Employee | Position_Id
ID | Employee | Position_Id
- here Position_Id
is the foreign key coming from the Positions
table ID
A user can have multiple Departments
. Departments
can have several Positions
, Positions
can have several Employees
. So, if the user is different, how can I get all the data from all 4 tables that this user created?
source share