From eb72b22b8b9b21c2cc61e72fe66230a1e9242b8d Mon Sep 17 00:00:00 2001 From: billalxcode Date: Fri, 8 Jul 2022 18:40:46 +0700 Subject: [PATCH] Update v1.1-rev3: Menambahkan pengaturan --- app/Controllers/Settings.php | 25 +++++++++++- app/Views/admin/settings/general.php | 60 +++++++++++++++++++++++----- 2 files changed, 75 insertions(+), 10 deletions(-) diff --git a/app/Controllers/Settings.php b/app/Controllers/Settings.php index 8d291ae..b795c2a 100644 --- a/app/Controllers/Settings.php +++ b/app/Controllers/Settings.php @@ -11,7 +11,7 @@ public function index() helper("form"); $this->context['title'] = "Kelola Pengaturan"; $this->context['values'] = $this->settingsModel->first(); - + $this->context['profiles'] = $this->usersModel->where('id', $this->context['usersData']['id'])->first(); return $this->renderView("admin/settings/general"); } @@ -44,6 +44,29 @@ public function save() { $this->session->setFlashdata('success', 'Berhasil menyimpan data'); return redirect()->back(); + } elseif ($type == 'profile') { + $userData = $this->usersModel->where('id', $this->context['usersData']['id'])->first(); + + $name = $this->request->getPost('name'); + $email = $this->request->getPost("email"); + $username = $this->request->getPost("username"); + $password = $this->request->getPost("password"); + + $name = isset($name) ? $name : $userData['name']; + $email = isset($email) ? $email : $userData['email']; + $username = isset($username) ? $username : $userData['username']; + $password = isset($password) ? password_hash($password, PASSWORD_BCRYPT) : $userData['password$password']; + + $data_post = [ + 'name' => $name, + 'email' => $email, + 'username' => $username, + 'password' => $password + ]; + + $this->usersModel->update($userData['id'], $data_post); + $this->session->setFlashdata('success', 'Berhasil menyimpan data.'); + return redirect()->back(); } } } diff --git a/app/Views/admin/settings/general.php b/app/Views/admin/settings/general.php index d0592bf..2036020 100644 --- a/app/Views/admin/settings/general.php +++ b/app/Views/admin/settings/general.php @@ -60,6 +60,7 @@ getFlashdata('errors')['kota'] ?> +
@@ -78,15 +79,56 @@