/** * Execute the console command. * * @return mixed */ public function fire(Dispatcher $dispatcher) { $dispatcher->fire('zip_codes.update.starting'); $this->counties = County::all(); $url = $this->getRemoteZipCodeFile(); $parser = app(RemoteZipCodeFileParser::class); $parser->parse($url, function (RemoteZipCodeObject $object) { $municipality = $this->updateMunicipality($object->municipality_id, $object->municipality_name); $this->updateZipCode($municipality, $object->id, $object->name); }); $dispatcher->fire(new ZipCodesUpdated($this->added, $this->changed)); }