Scalr\Model\Entity\Account\User::getTeams PHP Method

getTeams() public method

Gets user teams
public getTeams ( ) : array
return array
    public function getTeams()
    {
        return $this->db()->getAll('
            SELECT at.id, at.name
            FROM account_teams at
            JOIN account_team_users tu ON at.id = tu.team_id
            WHERE tu.user_id = ?
        ', array($this->id));
    }

Usage Example

Exemplo n.º 1
0
 /**
  * user.auth.login handler
  *
  * @param Scalr_Account_User|Entity\Account\User  $user  User object
  * @return array   Returns array of the fields to log
  */
 protected function handlerUserAuthLogin($user)
 {
     if ($user instanceof Scalr_Account_User || $user instanceof Entity\Account\User) {
         $this->user = $user;
         $teams = [];
         // Teams are needed for the audit log
         foreach ($user->getTeams() as $rec) {
             $teams[$rec['id']] = $rec['name'];
         }
         $lastVisit = $user->dtLastLogin ?: $user->dtCreated;
         $data = ['.result' => 'success', '.teams' => $teams, '.last_login' => $lastVisit ? static::getTimestamp(strtotime($lastVisit)) : null, '.user_type' => $user->type];
     }
     return isset($data) ? $data : $user;
 }
All Usage Examples Of Scalr\Model\Entity\Account\User::getTeams