Function edit works successfuly
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user