Function edit works successfuly

This commit is contained in:
2017-09-05 10:24:44 +07:00
parent c64064321e
commit 61060dd393
3 changed files with 45 additions and 12 deletions

View File

@@ -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();
}
}
}