samedi 30 mai 2020

Recursive query in laravel

I have a table user with a fields id,user_name,manager,geo .I want to get the user (a) and his repotee(b) and b' reportees and so on for the geo US .From the table I want to get the result as IF a login[a,c,d] if e login [e]

user_name   manager   geo
a            x        US
b            a        UK
c            a        US
d            b        US

e            Y        UE
f            e        US

I have tried as

$filter_username_details=DB::table('user_master as a')->leftjoin('user_master as b', 'a.reports_to', '=', 'b.user_name')->where('a.user_name',$user_name)->orwhere('a.reports_to',$user_name)->orwhere('b.reports_to',$user_name)->whereIn('a.geo',$geo)->groupBy('a.user_name')->pluck(
            'a.user_name')->toArray();

getting wrong output as loading all the value has 'US'



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire