public function productsBySubCatagory($id) { $query = Product::where('subcatagory_id', '=', $id)->paginate(12); $catagory = Catagory::all(); $subcatagory = Subcatagory::all(); return View::make('Products.ProductsByCatagory', ['catagories' => $catagory, 'products' => $query, 'subcatagories' => $subcatagory]); }
/** * Edit sub catagory page */ public function edit($slug) { $catagories = Subcatagory::where('slug', '=', $slug); if ($catagories->count() > 0) { return View::make('Subcatagories.Edit')->with('catagories', Catagory::all())->with('subcatagories', $catagories->get()); } else { App::abort(404); } }
@if (Session::has('event')) {{ Session::get('event') }} @endif </div> <section> <div class="container"> {{ Form::open(array('url' => 'dashboard/addProduct', 'files' => true)) }} <div class="form-group"> <div class="row"> <div class="col-md-2"> <label for="catagory">Catagories</label> </div> <div class="col-md-6"> <?php $query = Catagory::all(); ?> <select name="catagory" id="catagory"> @foreach ($query as $row) <option value="{{ $row->id }}">{{ $row->catagory_name }}</option> @endforeach </select> </div> </div> </div> {{-- Sub catagory div --}} <div class="form-group" id="subcatagory_div" style="display: none;"> <div class="row"> <div class="col-md-offset-2 col-md-6"> <select class="form-control" name="subcatagory" id="subcatagory"></select>
public function productsByCatagory($id) { $query = Product::where('catagory_id', '=', $id)->get(); $catagory = Catagory::all(); return View::make('users.products', ['query' => $catagory, 'products' => $query, 'cat_id' => $id]); }