/** * Get the option select category. * * @return String option format for select box */ public function selectBoxCategory($parent_id = 0, $split = '', $select_id = '') { $str_return = ''; $list_category = Category::with(['CategoryData' => function ($query) { $query->where('language_code', '=', AppLanguage::getDefaultLanguage()); }])->where('parent_id', '=', $parent_id)->get(); if ($list_category) { foreach ($list_category as $category) { foreach ($category->categoryData as $cate) { $category_id = $category->id; if ($category_id == $select_id) { $attribute_option = 'selected'; } else { $attribute_option = ''; } $str_return .= "<option value='" . $cate->category_blogs_id . "' " . $attribute_option . '>' . $split . $cate->category_name . '</option>'; } $str_return .= self::selectBoxCategory($category_id, '|---', $select_id); } } return $str_return; }
/** * Remove the specified resource from storage. * * @param int $id * * @return \Illuminate\Http\Response */ public function delete(Request $request) { $CategoryID = $request->route('category'); $categoryData = CategoryData::where('category_blogs_id', '=', $CategoryID)->delete(); // $categoryData->delete(); $Category = Category::find($CategoryID); $Category->delete(); return redirect()->route('cpanel.category.index'); }