protected function beforeCreate() { $this->name = $this->name ?: $this->username; $this->session_hash = sha1($this->username . uniqid() . microtime() . rand(0, 99999)); }