public function deleteSub() { if ($request->ajax()) { $sub_id = \Input::get('d'); $sub = \App\SubCat::whereId($sub_id)->first(); $sub->delete(); return redirect()->back(); } response(['msg' => 'Failed deleting the product', 'status' => 'failed']); }
public function subcat2() { $query = \Input::get('y'); $catId = \App\Cat::whereId($query)->first(); $desc = $catId->meta_description; $list = \App\SubCat::where('cat_id', '=', $query)->lists('name', 'id')->all(); if (count($list) > 0) { foreach ($list as $key => $value) { $data[] = array('id' => $key, 'text' => $value); } } else { $data[] = array('id' => '0', 'text' => 'No Subcategories found'); } return \Response::json(['data' => $data, 'desc' => $desc]); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $biz = Biz::findorFail($id); $cat = $biz->cats->lists('id')->all(); $sub = $biz->subcats->lists('id')->all(); // dd($sub); $catList = Cat::lists('name', 'id'); $subList = SubCat::lists('name', 'id'); // dd($subList); $stateList = State::lists('name', 'id'); $lgaList = Lga::lists('name', 'id'); //$area= Address::lists //dd($biz->address->state->name); // foreach ($biz->subcats as $sub) { // $currentSubs[] = $sub->id; // } // if(empty($currentSubs)){ // $currentSubs = ''; // } return view('admin/biz/edit', compact('biz', 'catList', 'subList', 'stateList', 'cat', 'currentSubs', 'lgaList', 'sub')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $cat = Cat::findOrFail($id); $list = $cat->subcats->lists('name')->all(); $image_class = Cat::lists('image_class', 'image_class'); $cats = Cat::lists('name', 'name'); $subcats = SubCat::lists('name', 'name'); // dd($cat->subcats->lists('id')->all()); // $data = ['id' => $id]; // foreach (array_keys($this->fields) as $field) { // $data[$field] = old($field, $cat->$field); // } return view('admin.cat.edit')->withCats($cats)->withCat($cat)->withSubcats($subcats)->withList($list)->withImage_class($image_class); }
public function bizSub($id) { $sub = SubCat::findOrFail($id); $bizs = $sub->biz; $cats = Cat::all(); $stateList = State::lists('name', 'name'); $catList = Cat::lists('name', 'name'); $loc = Input::get('location'); $featured = Biz::whereFeatured('YES')->paginate(3); $recent = Biz::orderBy('created_at', 'desc')->paginate(1); return view('pages.biz-sub', compact('bizs', 'stateList', 'catList', 'loc', 'cats', 'featured', 'recent', 'sub')); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(CatUpdateRequest $request, $id) { $cat = Cat::findOrFail($id); $cat->name = $request->input('name'); $cat->meta_description = $request->input('meta_description'); $cat->image_class = $request->input('image_class'); $cat->save(); $sub_cats = $request->input('sub_cats'); $real = []; $cat->subcats()->delete(); foreach ($sub_cats as $sub) { if ($existingCat = SubCat::where('name', $sub)->first()) { $real[] = $existingCat; } else { $newCat = new SubCat(); $newCat->name = $sub; $newCat->save(); $real[] = $newCat; } } $cat->subcats()->saveMany($real); return redirect("/admin/cat/")->withSuccess("Changes saved."); }