I have the table user which has user_name and manager name.I want to get the user name for who have manager ='test'.I want to get the user who are having ramya as manager and reportee's reportee
users table
SNO user_name manager
1 vani Ramya
2 ramya geetha
3 priya ramya
4 mani ramya
5 latha vani
6. hema Anitha
project table
code name owner customer_code
UTC-p1 project 1 latha UTC-C-p1
GST-p1 project 2 latha GST-c-p1
UTC-p1 project 3 vani UTC-C-p2
UTC-p1 project 4 bala UTC-C-p3
customer table
name code
UTC UTC-C-p1
GST GST-c-p1
the customer name is 'UTC' and I want to get the name ramya and ramya's reportee vani,priya and mani and get latha who is having vani as manager who is having ramya as manager. I want to get ramya,vani,priya,mani and latha and fetch the project only belongs to her hierarchy based on customer code.
$users = DB::table('users as a')
->select('a.user_name')
->leftJoin('users as b', 'a.manager', '=', 'b.user_name')
->where('a.user_name','Ramya')
->orwhere('a.manager','Ramya')
->orwhere('b.manager','Ramya')
->get(); //returns(ramya,vani,priya,mani and latha)
get the get the project name 'project 1' which is related to her hierarchy
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire