public function beforeSave() { if (!trim($this->name)) { if ($this->login) { $this->name = $this->login; } else { $this->name = 'No Name'; } } }