diff --git a/App/Controllers/Posts.php b/App/Controllers/Posts.php index b82133c..34d0a8c 100644 --- a/App/Controllers/Posts.php +++ b/App/Controllers/Posts.php @@ -42,12 +42,15 @@ class Posts $id = implode('', $id); $posts = $this->model->showSingle($id); $categories = $this->model->showCategories(); + $date = new \DateTime(); + $timestamp = $date->format("Y/m/d H:i:s"); // echo "You can edit exists data with id $id here"; // Nanti di replace sama twig view ke App\Views\Data\edit_pengumuman.html View::render( 'Data/edit_pengumuman.html', [ 'posts' => $posts, 'categories' => $categories, + 'timestamp' => $timestamp, 'token' => Token::generate() ] ); @@ -65,4 +68,15 @@ class Posts return $this->index(); } } + + public function put($args = []) + { + $table = 'pengumuman'; + $id = $args['id']; + unset($args['id']); + if ($this->model->update($table, $args, $id)) { + Session::flash('info', 'Data successfuly updated'); + return $this->index(); + } + } } diff --git a/App/Views/Data/edit_pengumuman.html b/App/Views/Data/edit_pengumuman.html index 4780e3d..08b0757 100644 --- a/App/Views/Data/edit_pengumuman.html +++ b/App/Views/Data/edit_pengumuman.html @@ -16,28 +16,47 @@
- - + +
- - + + {{ post.created_at }}
- - + + {{ post.creator }}
- - + + {{ post.expired_at }}
- - + + + {% if post.edited_at == "0000-00-00 00:00:00" %} + Tidak pernah + {% else %} + {{ post.edited_at }} + {% endif %} + + + +
+ + + + {% if post.editor == "0" %} + - + {% else %} + {{ post.editor }} + {% endif %} + + @@ -51,6 +70,6 @@
- + {% endblock %} diff --git a/Core/Router.php b/Core/Router.php index a67c9f9..45bda5a 100644 --- a/Core/Router.php +++ b/Core/Router.php @@ -82,7 +82,7 @@ class Router unset($var['_method']); } if (array_key_exists('id', $this->params)) { - $var[] = $this->params['id']; + $var['id'] = $this->params['id']; } if (isset($var)) { return $object->$action($var);