Ejemplo n.º 1
0
 public function cities($id)
 {
     return Cache::get('api.cities.' . $id, function () use($id) {
         $val = City::where('state_id', $id)->orderBy('order', 'desc')->orderBy('name', 'asc')->get()->pluck('id', 'name');
         Cache::put('api.cities.' . $id, $val, 60);
         return $val;
     });
 }
Ejemplo n.º 2
0
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     if (!$this->app->routesAreCached()) {
         $this->app->router->group(['namespace' => 'Mixdinternet\\Cities\\Http\\Controllers'], function () {
             require __DIR__ . '/../Http/routes.php';
         });
     }
     $this->publishes([__DIR__ . '/../database/migrations' => base_path('database/migrations')], 'migrations');
     $this->publishes([__DIR__ . '/../database/seeds' => base_path('database/seeds')], 'seeds');
     $this->app->router->bind('states', function ($id) {
         $state = State::find($id);
         if (!$state) {
             abort(404);
         }
         return $state;
     });
     $this->app->router->bind('cities', function ($id) {
         $city = City::find($id);
         if (!$city) {
             abort(404);
         }
         return $city;
     });
 }