Created
          July 6, 2016 23:40 
        
      - 
      
- 
        Save raank/39914e61cde48c74dc231631dac39e90 to your computer and use it in GitHub Desktop. 
    Função recursiva
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php namespace App\Services; | |
| use App\User; | |
| class NetWorkService { | |
| public function getUsers( $sponsor ) | |
| { | |
| $users = User::where('sponsor', 'LIKE', '%' . $sponsor . '%')->get(); | |
| foreach($users->toArray() as $user) { | |
| $network = (array) json_decode($user['sponsor']); | |
| $list[] = [ | |
| 'id' => $user['id'], | |
| 'login' => $user['name'], | |
| 'email' => $user['email'], | |
| 'name' => $user['nome'], | |
| 'network' => [ | |
| 'nivel' => $network['nivel'], | |
| 'pos' => $network['pos'] | |
| ], | |
| 'users' => $this->getUsers($user['name']) | |
| ]; | |
| } | |
| return ($users ? $list : null); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment