@ahmeddabak i have used the route than defined the controller written the
showsubcategory function in the contoller
public function showsubcategory(Request $request){
the problem calling the AJAX Request to the controller so i have called AJAX Request as below but the AJAX request passed only for if condition not for other if else so i need to call the AJAX request in if else condition
The problem calling the AJAX Request to the controller i have used if else condition.AJAx passes only for first if condition not for other if else condition.how to call the two or more AJAX request in the controller!!!
written AJAX request in controller
public function showsubcategory($id,$name,Request $request){
if($request->ajax()){
$start = $request->start;
$end = $request->end;
$product = DB::table('products')->select('*')
->where('category_id','=',$id)
->where('price','>=',$start)
->where('price','<=',$end)
->get();
$subcatdata = DB::table('categories')->select('*')->get();
response()->json($product);
return view ('displayproducts',compact('product','subcatdata'));
} else if(isset($request->color)){
$colors = $request->color;
dd($colors);
} else{
$subcategory = \App\Product::where('id',$id)->where('name',$name)->first();
$subcatdata = DB::table('categories')->select('*')->get();
$product = DB::table('products')->select('*')->where('category_id','=',$id)->get();
$prod = \App\Product::get();
$subids = $prod->pluck('attribute_id');
$attribute = \App\Attribute::whereIn('id', $subids)->get();
$brand = DB::table('brands')->select('*')->get();
return \view ('subcategory',compact('product','subcatdata','attribute',
'brand','catid'));
}