diff --git a/App/Controllers/Posts.php b/App/Controllers/Posts.php index f777a30..f94333e 100644 --- a/App/Controllers/Posts.php +++ b/App/Controllers/Posts.php @@ -209,6 +209,14 @@ class Posts public function put($args = []) { + if (isset($args['_addon'])) { + $table = $args['_addon']; + + $this->post->update($table, ['status' => 1], $args['id']); + + Session::flash('info', 'Data berhasil diaktifkan.'); + Redirect::to('/posts/category'); + } $args['content'] = htmlspecialchars($args['content']); $id = $args['id']; @@ -259,17 +267,26 @@ class Posts $id = $args['id']; - if ($this->post->delete($this->table, $id)) { - Session::flash('info', 'Data berhasil di nonaktifkan'); - - if ($this->table = 'kategori') { - Redirect::to('/posts/category'); - } elseif ($this->table = 'pengumuman') { - Redirect::to('/'); - } + if ($this->table == 'kategori') { + $delete = $this->post->delete($this->table, $id, 0); + } else { + $delete = $this->post->delete($this->table, $id); } + if ($delete == true) { + $info = 'Data berhasil dinonaktifkan.'; + } else { + $info = 'Terjadi kesalahan. Silahkan coba lagi dalam beberapa saat.'; + } // Return the $table back to default $this->table = 'pengumuman'; + + Session::flash('info', $info); + + if ($this->table = 'kategori') { + Redirect::to('/posts/category'); + } elseif ($this->table = 'pengumuman') { + Redirect::to('/'); + } } } diff --git a/App/Views/Data/kategori.html b/App/Views/Data/kategori.html index 100e0ff..0e03b83 100644 --- a/App/Views/Data/kategori.html +++ b/App/Views/Data/kategori.html @@ -9,16 +9,21 @@