php - route or cache in Laravel project -


i have laravel 5.4 project. there route issue can't solve second day. have 2 routes like:

route::get('/', 'homecontroller@index')->name('index');  public function index(cookiejar $cookiejar, request $request)     {         // Берем город из куков         $city_from_cookie = cookie::get('city');         // Если города нет в куках         if (!$city_from_cookie) {             $client = new client();             $ip = $request->ip() == '127.0.0.1' ? '95.85.70.7' : $request->ip();             $json = $client->request('get', 'http://freegeoip.net/json/' . $ip . '');             $city = json_decode($json->getbody()->getcontents());              if ($city->city === null) {                 $cookie = cookie('city', config('custom.city.default_slug'), 21600, null, null, false, true);                 $cookiejar->queue($cookie);                 $city = config('custom.city.default_slug');             } else {                 $city = strtolower($city->city);                  try {                     $city = city::findbyslugorfail($city);                     $city = $city->slug;                 } catch (modelnotfoundexception $ex) {                     $city = 'moskva';                 }                  $cookie = cookie('city', $city, 21600, null, null, false, false);                 $cookiejar->queue($cookie);             }          } else {             $city = $city_from_cookie;         }          return redirect(route('city', [$city]), 301);     } 

and

route::get('{city}', 'homecontroller@getcitycategories')->name('city');  public function getcitycategories(city $city, cookiejar $cookiejar)     { //        cache::flush(); //        dd(request()->getrequesturi());         $cookie = cookie('city', $city->slug, 21600, null, null, false, false);         $cookiejar->queue($cookie);          $categories = category::wherenull('parent_id')->with('subcategories')->get();          if ($city->weather_id) {             $weather = $this->getweather($city->weather_id);         } else {             $weather = [                 'city' => '',                 'temp_min' => '',                 'temp_max' => '',                 'day' => '',                 'symbol' => '',                 'symbol_desc' => ''             ];         }          return view('pages.categories', compact('categories', 'city', 'weather'));     } 

the problem if go '/' root first time method it's work when you're getting city /moskva , if change city example /abakan , go root '/' redirected /moskva. tried everything, turned off cahing, cleared cache artisan commands not helped. here domain testing issue: okololo.ru


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -