diff --git a/App/Controllers/Posts.php b/App/Controllers/Posts.php index 38330ae..bee34cc 100644 --- a/App/Controllers/Posts.php +++ b/App/Controllers/Posts.php @@ -163,9 +163,7 @@ class Posts { if (Session::exists('userid')) { if ($id) { - if (is_array($id)) { - $id = implode('', $id); - } + $id = implode('', $id); $get_categories = $this->model->showAll([ ['status', '=', 1] @@ -220,7 +218,7 @@ class Posts } } - public function category() + public function category($id = null) { if (Session::exists('userid')) { if (Session::get('privilege') != 1) { @@ -229,7 +227,19 @@ class Posts die(); } $categories = []; - $get_categories = $this->model->showAll([], 'kategori'); + $values = []; + $method = ''; + if ($id != null) { + $id = implode('', $id); + $get_categories = $this->model->showAll([ + ['id', '=', $id] + ], 'kategori'); + $method = 'put'; + $values = $get_categories; + } else { + $get_categories = $this->model->showAll([], 'kategori'); + $method = 'post'; + } if ($get_categories) { if (!array_key_exists(0, $get_categories)) { @@ -241,7 +251,9 @@ class Posts View::render('Data/kategori.html', [ 'categories' => $categories, - 'token' => Token::generate() + 'token' => Token::generate(), + 'method' => $method, + 'value' => $values ]); } else { throw new \Exception("Page not found", 404); @@ -293,7 +305,7 @@ class Posts $this->model->update($args, $args['id'], $table); - Session::flash('info', 'Data berhasil diaktifkan'); + Session::flash('info', 'Update berhasil'); Redirect::to('/posts/category'); die(); } diff --git a/App/Views/Data/edit_kategori.html b/App/Views/Data/edit_kategori.html deleted file mode 100644 index 7245f11..0000000 --- a/App/Views/Data/edit_kategori.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Ubah Kategori{% endblock %} - -{% block body %} - -
-
-
-
-

Kategori -

-

- -

- -
-
- -{% endblock %} diff --git a/App/Views/Data/kategori.html b/App/Views/Data/kategori.html index 72c0f30..752d195 100644 --- a/App/Views/Data/kategori.html +++ b/App/Views/Data/kategori.html @@ -5,7 +5,7 @@ {% block body %}
-

Kategori

+

Kategori

@@ -17,29 +17,34 @@
- +
- +
- +
- + @@ -58,7 +63,7 @@