public function getView($id) { if (isset($_GET['tocity']) && $_GET['tocity'] != "") { $product = Product::where('id', '=', $id)->first()->toArray(); $fetch_prod = Prodvenrelations::where('product_id', '=', $id)->where('city', 'like', "%" . $_GET['tocity'] . "%")->get()->toArray(); $other_ven = array(); if (count($fetch_prod) > 1) { foreach ($fetch_prod as $k => $v) { $other_ven[$k] = (object) $v; } } $nodata = 1; if (!empty($fetch_prod)) { $product['vendor_id'] = $fetch_prod[0]['vendor_id']; $product['regular_price'] = $fetch_prod[0]['regular_price']; $product['delux_price'] = $fetch_prod[0]['delux_price']; $product['premium_price'] = $fetch_prod[0]['premium_price']; $product['description'] = $fetch_prod[0]['description']; } else { $product = (array) $product; if ($product['city'] == $_GET['tocity']) { $nodata = 1; } else { $nodata = 0; } } $product = (object) $product; $addon_items = Addon::all(); return View::make('home.view')->with('product', $product)->with('other_ven', $other_ven)->with('addon_items', $addon_items)->with('nodata', $nodata); } else { $nodata = 1; $product = Product::find($id); $vendor_id = $product->vendor_id; $vendor_items = Product::where('vendor_id', '=', $vendor_id)->get(); $addon_items = Addon::all(); $other_ven = array(); if (trim($product->ovid) != "") { $ovid_val = ltrim($product->ovid, ','); $arr = explode(',', $ovid_val); foreach ($arr as $key => $value) { $other_ven[] = Prodvenrelations::find($value); } } return View::make('home.view')->with('product', $product)->with('vendor_items', $vendor_items)->with('other_ven', $other_ven)->with('addon_items', $addon_items)->with('nodata', $nodata)->with('city_list', City::all()); } }