public function updateCategory(Request $data)
 {
     $userid = Auth::user()->id;
     if ($data->isMethod('post')) {
         $categoryid = $data->input('editcategoryid');
         $categoryname = $data->input('editcategoryname');
         $categorystatus = $data->input('editcategorystatus');
         $this->validate($data, ['editcategoryname' => 'required'], ['editcategoryname.required' => 'Invalid Name']);
         $categoryData = array();
         $categoryData['category_name'] = $categoryname;
         $categoryData['status'] = $categorystatus;
         $categoryData['user_id'] = $userid;
         $objCategory = new category();
         $result = $objCategory->updateCategory($categoryid, $categoryData);
         //             die($result);
         if ($result) {
             return redirect('/admin/category');
         } else {
             return redirect('/admin/category')->withErrors(['errMsg' => 'Update Not Changed']);
         }
     }
 }
Example #2
0
if (isset($_GET['action']) && $_GET['action'] == 'new') {
    $smarty->assign('content', $smarty->fetch('addcategory.tpl'));
} elseif (isset($_GET['action']) && $_GET['action'] == 'edit') {
    $id = $_GET['id'];
    $categories = $category->getCategory($id);
    $smarty->assign('category', $categories);
    $smarty->assign('content', $smarty->fetch('editcategory.tpl'));
} elseif (isset($_POST['action']) && $_POST['action'] == 'add') {
    $data = $_POST;
    if ($category->addCategory($data)) {
        header('Location: ' . FRONTEND . 'category.php');
        exit;
    }
} elseif (isset($_POST['action']) && $_POST['action'] == 'update') {
    $data = $_POST;
    if ($category->updateCategory($data)) {
        header('Location: ' . FRONTEND . 'category.php');
        exit;
    }
} elseif (isset($_GET['action']) && $_GET['action'] == 'search') {
    $keyword = $_POST['keywords'];
    $smarty->assign('categories', $category->getSearchCategories($keyword));
    $smarty->assign('content', $smarty->fetch('category.tpl'));
} else {
    $smarty->assign('categories', $categories);
    $smarty->assign('content', $smarty->fetch('category.tpl'));
}
$smarty->display('two-column-left.html');
?>