Fix categories issues
This commit is contained in:
parent
aec3b73730
commit
eeaa2427a0
@ -112,7 +112,15 @@ class Posts
|
||||
$date = new \DateTime();
|
||||
$now = $date->format("Y-m-d");
|
||||
|
||||
$categories = $this->model->showAll([], 'kategori');
|
||||
$get_categories = $this->model->showAll([
|
||||
['status', '=', 1]
|
||||
], 'kategori');
|
||||
|
||||
if (array_key_exists(0, $get_categories)) {
|
||||
$categories = $get_categories;
|
||||
} else {
|
||||
$categories[] = $get_categories;
|
||||
}
|
||||
|
||||
$user = Session::get('userid');
|
||||
|
||||
@ -135,7 +143,15 @@ class Posts
|
||||
$id = implode('', $id);
|
||||
}
|
||||
|
||||
$categories = $this->model->showAll([], 'kategori');
|
||||
$get_categories = $this->model->showAll([
|
||||
['status', '=', 1]
|
||||
], 'kategori');
|
||||
|
||||
if (array_key_exists(0, $get_categories)) {
|
||||
$categories = $get_categories;
|
||||
} else {
|
||||
$categories[] = $get_categories;
|
||||
}
|
||||
|
||||
$post = $this->model->showAll([
|
||||
['id', '=', $id]
|
||||
@ -182,7 +198,14 @@ class Posts
|
||||
public function category()
|
||||
{
|
||||
if (Session::exists('userid')) {
|
||||
$categories = $this->model->showAll([], 'kategori');
|
||||
$categories = [];
|
||||
$get_categories = $this->model->showAll([], 'kategori');
|
||||
|
||||
if (!array_key_exists(0, $get_categories)) {
|
||||
$categories[] = $get_categories;
|
||||
} else {
|
||||
$categories = $get_categories;
|
||||
}
|
||||
|
||||
View::render('Data/kategori.html', [
|
||||
'categories' => $categories,
|
||||
@ -204,7 +227,7 @@ class Posts
|
||||
foreach ($args as $value) {
|
||||
if ($value == '') {
|
||||
Session::flash('info', 'Semua data harus diisi.');
|
||||
if ($table) {
|
||||
if (isset($table)) {
|
||||
Redirect::to("/posts/category");
|
||||
} else {
|
||||
Redirect::to('/posts/entry');
|
||||
@ -213,7 +236,11 @@ class Posts
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($args['content'])) {
|
||||
$args['content'] = htmlspecialchars($args['content']);
|
||||
} elseif (isset($args['category'])) {
|
||||
$args['category'] = htmlspecialchars($args['category']);
|
||||
}
|
||||
|
||||
if (isset($table)) {
|
||||
if ($this->model->entry($args, $table)) {
|
||||
|
Loading…
Reference in New Issue
Block a user