diff --git a/App/Controllers/Posts.php b/App/Controllers/Posts.php index 5481b11..8580831 100644 --- a/App/Controllers/Posts.php +++ b/App/Controllers/Posts.php @@ -45,18 +45,18 @@ class Posts if (is_array($id)) { $id = implode('', $id); } - $posts = $this->post->showSingle($id); + $post = $this->post->showSingle($id); $categories = $this->post->showCategories(); - $users = $this->access->showSingle($id); + $user = $this->access->showSingle($id); $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, + 'post' => $post, 'categories' => $categories, - 'users' => $users, + 'user' => $user, 'timestamp' => $timestamp, 'token' => Token::generate() ] diff --git a/App/Models/Post.php b/App/Models/Post.php index 71341e7..a5197fa 100644 --- a/App/Models/Post.php +++ b/App/Models/Post.php @@ -63,7 +63,7 @@ class Post extends \Core\Model if ($query->execute([$id])) { if ($query->rowCount() === 1) { - $result = $query->fetchAll(\PDO::FETCH_ASSOC); + $result = $query->fetch(\PDO::FETCH_ASSOC); return $result; } } diff --git a/App/Views/Data/edit_pengumuman.html b/App/Views/Data/edit_pengumuman.html index 6abf107..3450b78 100644 --- a/App/Views/Data/edit_pengumuman.html +++ b/App/Views/Data/edit_pengumuman.html @@ -3,124 +3,118 @@ {% block title %}Edit Pengumuman{% endblock %} {% block body %} - {% for post in posts %} +
+ + {% if post.status == 1 %} - - {% if post.status == 1 %} - - {% endif %} - {% endfor %} + {% endif %} {% endblock %}