diff --git a/App/Controllers/Posts.php b/App/Controllers/Posts.php
index 44fe10e..f54ec05 100644
--- a/App/Controllers/Posts.php
+++ b/App/Controllers/Posts.php
@@ -154,7 +154,9 @@ class Posts
['id', '=', $editor]
], $table);
- $editor_now = Session::get('userid');
+ $editor_now = $this->model->showAll([
+ ['id', '=', Session::get('userid')]
+ ], $table);
$date = new \DateTime();
$timestamp = $date->format("Y-m-d");
@@ -310,4 +312,18 @@ class Posts
}
die();
}
+
+ public function remove($args = [])
+ {
+ $id = $args['id'];
+ if ($this->model->remove($id) == true) {
+ $info = 'Data berhasil dihapus';
+ } else {
+ $info = 'Terjadi kesalahan. Silahkan coba lagi dalam beberapa saat.';
+ }
+
+ Session::flash('info', $info);
+ Redirect::to('/');
+ die();
+ }
}
diff --git a/App/Models/Post.php b/App/Models/Post.php
index 7870c2d..716cceb 100644
--- a/App/Models/Post.php
+++ b/App/Models/Post.php
@@ -241,4 +241,20 @@ class Post extends \Core\Model
throw new \Exception($e->getMessage(), 444);
}
}
+
+ public function remove($id) {
+ try {
+ $db = static::connectDB();
+
+ $sql = "DELETE FROM pengumuman WHERE id = ?";
+
+ $query = $db->prepare($sql);
+ $query->bindValue(1, $id);
+ $query->execute();
+ return true;
+ } catch (PDOException $e) {
+ throw new \Exception($e->getMessage(), 444);
+ }
+
+ }
}
diff --git a/App/Views/Data/edit_pengumuman.html b/App/Views/Data/edit_pengumuman.html
index fa7a93a..06724f9 100644
--- a/App/Views/Data/edit_pengumuman.html
+++ b/App/Views/Data/edit_pengumuman.html
@@ -74,7 +74,7 @@
{{ editor.full_name }}
{% endif %}
-
+
@@ -101,7 +101,7 @@
- {% if (post.status == 1 and editor_now == creator.id) %}
+ {% if (post.status == 1 and editor_now.id == creator.id) %}