/** * Set new avatar * * @return mixed */ public function setAvatarAction() { if ($this->getRequest()->isPost()) { $user = new User(); $user->user_avatar = $this->getRequest()->file('avatarupload'); $validator = new Validator($user); if ($validator->isAvatarValid()) { $user->avatarSave(); } else { $error = $validator->getErrors(); } } return true; }
/** * Save avatar * * @return \Framework\Response\Response */ public function avatarAction() { if ($this->getRequest()->isPost()) { $user = new User(); $user->user_avatar = $this->getRequest()->file('avatarupload'); $validator = new Validator($user); if ($validator->isAvatarValid()) { $user->avatarSave(); } else { $error = $validator->getErrors(); } } $profile = User::findInfo(); return $this->render('profile.html', ['info' => $profile, 'errors' => isset($error) ? $error : null]); }