/** * Show the application welcome screen to the user. * * @return Response */ public function index() { DB::connection()->enableQueryLog(); $data['location'] = GeoIP::getLocation(); $l_city = $data['location']['city']; $l_state = $data['location']['state']; $agent = new Agent(); $get_city = \App\City::where('city', '=', $l_city)->take(1)->get(); if (count($get_city) != 0) { foreach ($get_city as $c) { $city = $c->id; } } else { $city = 894; $data['location']['city'] = 'Phoenix'; $data['location']['state'] = 'AZ'; } $data['recent_restaurants'] = \App\Restaurants::where('having_menu', '=', '1')->where('city_id', '=', $city)->orderBy(DB::raw('RAND()'))->take(4)->get(); $data['recent_reviews'] = \App\Restaurant_Reviews::orderBy(DB::raw('RAND()'))->leftJoin('restaurants', 'restaurants_reviews.restaurants_id', '=', 'restaurants.id')->leftJoin('city', 'restaurants.city_id', '=', 'city.id')->leftJoin('state', 'restaurants.state_id', '=', 'state.id')->take(6)->get(); //$data['nearest_zip'] = \App\Zip::where('zip', '>', (int)session('geoip-locations.postal_code')-10)->where('zip', '<', (int)session('geoip-locations.postal_code')+10) // ->take(5)->get(); //dd(DB::getQueryLog()); //dd($data['recent_reviews']); if ($agent->isMobile()) { return view('mobile_home')->with($data); } else { return view('home')->with($data); } }
Route::get('/landing', function () { return View::make('landing'); }); Route::get('/landing_with_menu', function () { return View::make('landing_menu'); }); //Route::get('home', 'HomeController@index'); Route::post('search/autocomplete', array('as' => 'search', 'uses' => 'SearchController@autocomplete')); Route::post('/search', array('as' => 'search', 'uses' => 'SearchController@homeSearch')); Route::get('/search', array('as' => 'search', 'uses' => 'SearchController@bannerSearch')); Route::get('restaurants/request_online_order', function () { return View::make('search'); }); Route::post('/restaurants/request_online_order', 'RestaurantsController@request_online_order'); Route::get('/restaurants/next_reviews/{id}', function ($id) { $data['reviews'] = \App\Restaurant_Reviews::where('restaurant_id', '=', $id)->paginate(50); return View::make('next_review_box')->with('data', $data); }); Route::post('restaurants/request_online_ordering', array('as' => 'request_online_ordering', 'uses' => function () { $data['avail'] = \App\User_Request_Demo::where('email', '=', Input::get('guest_email'))->where('restaurants_id', '=', Input::get('r_id'))->get(); if (count($data['avail']) == 0) { $re = DB::table('user_request_demo')->insert(['restaurants_id' => Input::get('r_id'), 'first_name' => Input::get('guest_first_name'), 'last_name' => Input::get('guest_last_name'), 'email' => Input::get('guest_email'), 'request_type_id' => Input::get('r_t')]); \App\Restaurants::where('id', '=', Input::get('r_id'))->increment('request_order'); } else { echo '<script>alert("You have already been registered with us. Thank you for your interest");</script>'; } return Redirect::intended('restaurants/' . Input::get('rlink')); })); Route::get('10-Best/{category_name}/{city_name}', function ($category_name, $city_name) { DB::connection()->enableQueryLog(); $data['locations'] = GeoIP::getLocation();