Now can edit a category
This commit is contained in:
@@ -163,9 +163,7 @@ class Posts
|
||||
{
|
||||
if (Session::exists('userid')) {
|
||||
if ($id) {
|
||||
if (is_array($id)) {
|
||||
$id = implode('', $id);
|
||||
}
|
||||
$id = implode('', $id);
|
||||
|
||||
$get_categories = $this->model->showAll([
|
||||
['status', '=', 1]
|
||||
@@ -220,7 +218,7 @@ class Posts
|
||||
}
|
||||
}
|
||||
|
||||
public function category()
|
||||
public function category($id = null)
|
||||
{
|
||||
if (Session::exists('userid')) {
|
||||
if (Session::get('privilege') != 1) {
|
||||
@@ -229,7 +227,19 @@ class Posts
|
||||
die();
|
||||
}
|
||||
$categories = [];
|
||||
$get_categories = $this->model->showAll([], 'kategori');
|
||||
$values = [];
|
||||
$method = '';
|
||||
if ($id != null) {
|
||||
$id = implode('', $id);
|
||||
$get_categories = $this->model->showAll([
|
||||
['id', '=', $id]
|
||||
], 'kategori');
|
||||
$method = 'put';
|
||||
$values = $get_categories;
|
||||
} else {
|
||||
$get_categories = $this->model->showAll([], 'kategori');
|
||||
$method = 'post';
|
||||
}
|
||||
|
||||
if ($get_categories) {
|
||||
if (!array_key_exists(0, $get_categories)) {
|
||||
@@ -241,7 +251,9 @@ class Posts
|
||||
|
||||
View::render('Data/kategori.html', [
|
||||
'categories' => $categories,
|
||||
'token' => Token::generate()
|
||||
'token' => Token::generate(),
|
||||
'method' => $method,
|
||||
'value' => $values
|
||||
]);
|
||||
} else {
|
||||
throw new \Exception("Page not found", 404);
|
||||
@@ -293,7 +305,7 @@ class Posts
|
||||
|
||||
$this->model->update($args, $args['id'], $table);
|
||||
|
||||
Session::flash('info', 'Data berhasil diaktifkan');
|
||||
Session::flash('info', 'Update berhasil');
|
||||
Redirect::to('/posts/category');
|
||||
die();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user