From e7b5eec29d729a1c6c526149e283b9d2d46bf201 Mon Sep 17 00:00:00 2001 From: Gregorio Chiko Putra Date: Mon, 4 Sep 2017 14:47:30 +0700 Subject: [PATCH] Create conditions if no id is given. --- App/Controllers/Posts.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/App/Controllers/Posts.php b/App/Controllers/Posts.php index 5cd0516..3823c8f 100644 --- a/App/Controllers/Posts.php +++ b/App/Controllers/Posts.php @@ -19,10 +19,13 @@ class Posts return true; } - public function edit($id) + public function edit($id = null) { - 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'); - return true; + if ($id) { + 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'); + return true; + } + return false; } }