account === null) { $this->account = Account::findOne([$this->getLoginAttribute() => $this->getLogin()]); } return $this->account; } public function getLoginAttribute() { return strpos($this->getLogin(), '@') ? 'email' : 'username'; } }