add profile routs
This commit is contained in:
@ -150,7 +150,47 @@ class UserController extends AdminController
|
||||
if (!$user){
|
||||
throw new Exception(message: "The user not found");
|
||||
}
|
||||
$this->cgView->render("view.php", ['user' => $user]);
|
||||
$this->cgView->render("view_profile.php", ['user' => $user]);
|
||||
}
|
||||
|
||||
public function actionProfileUpdate(): void
|
||||
{
|
||||
$model = UserService::getAuthUser();
|
||||
if (!$model){
|
||||
throw new Exception(message: "The user not found");
|
||||
}
|
||||
|
||||
$this->cgView->render("form_profile.php", ['model' => $model]);
|
||||
}
|
||||
|
||||
public function actionProfileEdit(): void
|
||||
{
|
||||
$user = UserService::getAuthUser();
|
||||
if (!$user){
|
||||
throw new Exception(message: "The user not found");
|
||||
}
|
||||
|
||||
$userForm = new CreateUserForm();
|
||||
$userService = new UserService();
|
||||
$userForm->load($_REQUEST);
|
||||
|
||||
if (isset($_FILES['user_photo']) && $_FILES['user_photo']['error'] === UPLOAD_ERR_OK) {
|
||||
$file = new FileUpload($_FILES['user_photo'], ['jpg', 'jpeg', 'png']);
|
||||
$file->upload();
|
||||
$userForm->setItem('user_photo', $file->getUploadFile());
|
||||
}
|
||||
|
||||
if ($userForm->validateForUpdate()){
|
||||
$user = $userService->update($userForm, $user);
|
||||
|
||||
$entityRelation = new EntityRelation();
|
||||
$entityRelation->saveEntityRelation(entity: "user", model: $user, request: new Request());
|
||||
|
||||
if ($user){
|
||||
$this->redirect("/admin/user/profile");
|
||||
}
|
||||
}
|
||||
$this->redirect("/admin/user/profile/update");
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user