1 month ago

Recursive static function always returns null

Posted 1 month ago by lishaliu

I encountered a strange problem when trying to use recursive function to retrieve the top level of an agent:

 public static function getTopAgent($agent)
        if ($agent) {
            $supAgent = $agent->supAgent();
            if (!$supAgent) {
                // dd($agent);
                return $agent;
            } else {

I tried dd($agent), and everything is right, but if I use returnto get the result ,it always returns null

There is no other issue popped, I used var_dump , and it prints the correct result too, just can not figure out why.

Please sign in or create an account to participate in this conversation.