jeudi 17 mai 2018

LAravel 505 error

This has been giving a 404 ";page error not found" and for the life of me i dont't know why.

 public static function getGeneration($currentParent, $rootParent){
    // dd($rootParent);
    $user = User::where("username", $currentParent)->first();

    $generation =[];
    $x = 0;
    $bool = true;

     while ($bool) {

        if($x==0){
            $generation[$x] = (User::where("username", $user->sponsor_username)
                                ->firstOrfail())
                                ->sponsor_username;
        }else{
            $generation[$x] = (User::where("username", $generation[$x-1])
                                ->firstOrfail())
                                ->sponsor_username;

        }

        if( $x > 0 ){
            if($news = $generation[$x] == $rootParent){
                dd($news);
                $bool = false;

            }
        }


        $x++;
     }
     return $generation;
}

what this method basicaly does is go through a database and find out who brought a particular user into a system, because is user has a sponsor_username against it on the database, the last if statement is meant to stop when it discovers that it has reached the root user.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire