public function deleteAction($id = false) { $this->permission('delete'); if (!$id) { return Brightery::error404(); } $model = new \modules\blog\models\Blog_categories(); $model->blog_category_id = $id; if ($model->delete()) { Uri_helper::redirect("management/blog_categories"); } }
public function postAction($seo = null) { if (!$seo) { return Brightery::error404(); } $userInfo = $this->permissions->getUserInformation(); $model = new \modules\blog\models\Blog_posts(); $categories = new \modules\blog\models\Blog_categories(); $comments = new \modules\blog\models\Blog_post_comments($userInfo ? 'registered' : 'unregistered'); $comments->_joins = ['users' => ['users.user_id = blog_post_comments.user_id', 'left']]; $model->seo = $seo; $item = $model->get(); if (!$item) { return Brightery::error404(); } if ($userInfo) { $comments->set(['name' => $userInfo->fullname, 'email' => $userInfo->email, 'user_id' => $userInfo->user_id, 'comment' => $this->input->post('comment'), 'datetime' => date('Y-m-d H:i:s')]); } else { $comments->set(['name' => $this->input->post('name'), 'email' => $this->input->post('email'), 'comment' => $this->input->post('comment'), 'datetime' => date('Y-m-d H:i:s')]); } $comments->blog_post_id = $item->blog_post_id; $comments->save(); return $this->render('blog/post', ['item' => $item, 'categories' => $categories->get(), 'comments' => $comments->get(), 'comments_no' => $comments->get(1), 'user' => $userInfo]); }