/**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     $ftp = Storage::disk('ftp');
     $list = $ftp->files('commands_response');
     $count = 0;
     //$file = $list[0];
     foreach ($list as $file) {
         $filename = basename($file);
         $this->info(Carbon::now()->toDateTimeString() . " - Processando arquivo {$file}");
         if ($content = $ftp->read($file)) {
             $xml = simplexml_load_string($content);
             $ftp->delete($file);
         }
         $command = CommandXML::where('id_command', xmlGetVal($xml, 'ID_COMMAND'))->first();
         $response = new CommandsResponse();
         //['command_id', 'fragment_number', '', '', '', '', 'timestamp']
         $response->fragment_number = xmlGetVal($xml, 'FRAGMENT_NUMBER', 'int');
         $response->fragment_count = xmlGetVal($xml, 'FRAGMENT_COUNT', 'int');
         $response->attempt = xmlGetVal($xml, 'ATTEMPT', 'int');
         $response->sts_id = xmlGetVal($xml, 'STS_ID', 'int');
         $response->timestamp = xmlGetVal($xml, 'STS_TIMESTAMP', 'str');
         $response->desc = xmlGetVal($xml, 'DESC', 'str');
         $command->Responses()->save($response);
         $count++;
     }
     if ($count > 0) {
         $this->info("{$count} Respostas de Comandos processadas!");
     } else {
         $this->error("Nenhuma Resposta de Comando encontrada!");
     }
 }
 public function edit(Request $request)
 {
     $id = $request->show;
     $command = Command::find($id);
     $responses = $command->Responses->all();
     $form = \DataForm::create();
     //dd($command->Device->serial);
     $form->label = $command->id_command;
     $form->add('device', 'Aparelho', 'text')->insertValue($command->Device->serial)->mode('readonly');
     $form->add('created_at', 'Data do envio', 'text')->insertValue($command->created_at)->mode('readonly');
     $form->link("/commands", "Voltar", "TR")->back();
     return $form->view('commands::edit', compact('form', 'responses'));
 }