protected function showForm($mode, $category_id, $id = null) { $category = Category::find($category_id); if (count($category) > 0) { if ($id) { if (!($subcategory = subcategory::find($id))) { return Redirect()->to('subcategory'); } } else { $subcategory = ''; } return View('user.subcategories.form', compact('mode', 'category', 'subcategory')); } else { return Redirect()->back()->withErrors(trans('validation.categoryid-problem')); } }