public function subcategory_status($id) { DB::transaction(function ($id) use($id) { //this code for Sub category status inactive ..... $data = SubCategoryModel::where('category_id', $id)->get(); foreach ($data as $d) { if ($d->status == 1) { //check for product....... $this->product_status($d->id); //check for product inactive $SubCat = SubCategoryModel::findOrfail($d->id); $SubCat->update(['status' => 0]); } } // upto this ..... // DB::table('users')->update(array('votes' => 1)); // DB::table('posts')->delete(); }); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $data = ProductModel::where('id', $id)->get(); $cat = CategoryModel::where('status', 1)->get(); $subcat = SubCategoryModel::where('status', 1)->get(); // dd($data); return view('admin.pages.product.product_edit')->with('data', $data)->with('cat', $cat)->with('subcat', $subcat); }
/** * * * @return type category collection */ public static function getSubCategoryByCategory($id) { return SubCategoryModel::where('category_id', '=', $id); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $data = SubCategoryModel::findOrfail($id); $data->delete($id); return redirect()->route('subcategory_view')->with('message', 'subcategory data delete successfully.....'); }