public function getSubCategories(Request $request)
 {
     if (Auth::user()->email == '*****@*****.**') {
         $categories = ProductCategories::all();
         $sub_categories = DB::table('product_sub_categories')->where('in_category', $request->input('category-id'))->orderBy('position', 'asc')->get();
         return view('admin.sub-categories')->with('categories', $categories)->with('sub_categories', $sub_categories);
     }
     return redirect('/');
 }
 public function getViewModels(Request $request, $id)
 {
     if ($request->input('subcategory-id') == '') {
         $products = DB::table('products')->where('model', $id)->orderBy('id', 'desc')->paginate(18);
     } else {
         $products = DB::table('products')->where('model', $id)->where('sub_category', $request->input('subcategory-id'))->orderBy('id', 'desc')->paginate(500);
     }
     $categories = ProductCategories::all();
     $subcategories = SubProductCategories::all();
     $currentPath = $request->url();
     $models = Models::findOrFail($id);
     $productImages = DB::table('product_images')->get();
     $count = 0;
     // making clearfix for latest products
     return view('pages.view-model')->with('products', $products)->with('categories', $categories)->with('subcategories', $subcategories)->with('currentPath', $currentPath)->with('models', $models)->with('productImages', $productImages)->with('count', $count);
 }