public function createUser()
 {
     $user = User::create(['firstname' => Input::get('firstname'), 'surname' => Input::get('surname'), 'email' => Input::get('email'), 'password' => bcrypt(Input::get('password'))]);
     $rep = new LeaguesRepository();
     $rep->AddUserToGlobalLeagues($user->id);
     Auth::attempt(Input::only('email', 'password'));
     return response()->json(array('user' => $user, 'success' => true));
 }
 public function joinLeague($code)
 {
     $leagueRep = new LeaguesRepository();
     $portfolioRep = new PortfoliosRepository();
     $user = Auth::user();
     $league = $leagueRep->GetLeagueByCode($code);
     if ($league == null) {
         return array('success' => false, 'message' => 'connot find a league for code: ' . $code);
     }
     if ($portfolioRep->DoesLeaguePortfolioExist($user->id, $league->id)) {
         return array('success' => false, 'message' => 'You already belong to this league');
     }
     $leagueRep->AddUserToLeague($user->id, $league->id, $league->initial_balance);
     return array('success' => true, 'id' => $league->id);
 }