Example #1
0
 public function subcat(Request $req)
 {
     $html = '<option value="" selected>Choose Option</option>';
     $category_id = $req->id;
     $subcat_level1 = SubCatLevel1::where('category_id', $category_id)->get();
     foreach ($subcat_level1 as $Subcat_level1) {
         $html .= '<option value="' . $Subcat_level1->id . '">' . $Subcat_level1->name . '</option>';
     }
     echo $html;
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id, $sid)
 {
     $catDetails = Category::where('id', $id)->with(['products' => function ($query) use($sid) {
         $query->where('subcat_id', $sid);
     }])->first();
     /*
             $catDetails = \App\Category::where('id', $id)->
        with('product')->first();
     */
     $subCatDesc = SubCatLevel1::find($sid)->description;
     return view('category', ['subCatDesc' => $subCatDesc])->with('catDetails', $catDetails);
 }