public function autocomplete(IlluminateRequest $request)
 {
     $suggestions = array();
     $query = Request::input('query');
     // We could add similar functionality here for searching by other fields and result sets (i.e. "What movies were shot here?")
     $titles = FilmingLocation::select('title', 'location')->where('title', 'LIKE', "%{$query}%")->orWhere('location', 'LIKE', "%{$query}%")->groupBy('title')->get();
     $autocompleteResponse = new AutocompleteResponse($titles->toArray());
     return response()->json($autocompleteResponse->getStructuredResponse());
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     FilmingLocation::chunk(200, function ($locations) {
         foreach ($locations as $location) {
             if ($location->google_geocoding_cache_id == null) {
                 $event = new NewLocationAdded($location);
                 Event::fire($event);
             }
         }
     });
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $dataFile = fopen($this->argument('data-file'), "r");
     if ($dataFile) {
         $rowCounter = 0;
         while (($rowData = fgetcsv($dataFile, 0, ",")) !== FALSE) {
             if (0 === $rowCounter) {
                 $headerRecord = $rowData;
             } else {
                 $location = new FilmingLocation();
                 foreach ($rowData as $key => $value) {
                     $attribute = $headerRecord[$key];
                     $location->{$attribute} = $value;
                 }
                 $location->save();
                 $this->info("Record for {$location->location} added to database.");
             }
             $rowCounter++;
         }
         fclose($dataFile);
     }
 }