public function getprices(Request $request) { if ($request->id) { $price = Price::where('product_id', $request->id)->lists('price'); } else { $price = Price::lists('price'); } return response()->json($price); }