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();
     });
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     //        dd($id);
     $data = ProductModel::findOrfail($id);
     if ($data->status == 0) {
         //check for category.....
         $cat_info = CategoryModel::findOrfail($data->category_id);
         if ($cat_info->status == 1) {
             //check for sub category.....
             $subcat_info = SubCategoryModel::findOrfail($data->subcategory_id);
             if ($subcat_info->status == 1) {
                 ProductModel::where('id', $id)->update(['status' => 1]);
                 return redirect()->route('product_view')->with('message', 'status change successfully.....');
             } else {
                 return redirect()->route('product_view')->with('message', 'please Active sub category first.....');
             }
             // sub category checking complete.....
         } else {
             return redirect()->route('product_view')->with('message', 'please Active category first.....');
         }
         // category checking complete.....
     } elseif ($data->status == 1) {
         ProductModel::where('id', $id)->update(['status' => 0]);
         return redirect()->route('product_view')->with('message', 'status change successfully.....');
     }
 }
 /**
  * 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.....');
 }