Exemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     try {
         $data = $this->argument('data');
         if (filter_var($data, FILTER_VALIDATE_URL)) {
             // need to download file
             $data = FileUtilities::importUrlFileToTemp($data);
         }
         if (is_file($data)) {
             $data = file_get_contents($data);
         }
         $format = $this->option('format');
         $format = DataFormats::toNumeric($format);
         $this->comment($format);
         $service = $this->option('service');
         $resource = $this->option('resource');
         $result = ServiceHandler::handleRequest(Verbs::POST, $service, $resource, [], $data, $format);
         $this->info('Import complete!');
     } catch (\Exception $e) {
         $this->error($e->getMessage());
     }
 }