It's may be my question not clear to you but my English is weak. so suppose, I have two tables 'user' and 'project'. this project table contain two foreign keys from user table.
That's because, I want to indicate two people
(1) person who implement the project (Employee) (2) person who Mange or supervise the project (Manager)
user project -------------------- ----------------------------------------- user_id | name | |p_id | name | manager_id | employee_id | -------------------- ----------------------------------------- 001 | manager | p001 |ABC | 001 | 002 002 | employee |
you can see, project table refer user id as foreign key (manager_id and employee_id). because those two persons are users initially.
My question is, How can i get these users same time separately by using php laravel (Laravel Framework 5.5.45) when i am gonna show project details such as below?
Project ------------------------- project Name : ABC Manage By : manager Conduct By : employee -------------------------
I have found MySQL query but i haven't it right now to post here. i forgot to bookmark that stack overflow link.
You can use eloquent relationship for this. Use two relation in your Project Model like below:
So in view it will be something like
Check out Laravel Eloquent Relationship here