/**
  * 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);
     }
 }