コード例 #1
0
 public function handle()
 {
     $this->commandData->modelName = $this->argument('model');
     $this->commandData->useSoftDelete = $this->option('softDelete');
     $this->commandData->useSearch = $this->option('search');
     $this->commandData->fieldsFile = $this->option('fieldsFile');
     $this->commandData->initVariables();
     if ($this->commandData->fieldsFile) {
         $fileHelper = new FileHelper();
         try {
             if (file_exists($this->commandData->fieldsFile)) {
                 $filePath = $this->commandData->fieldsFile;
             } else {
                 $filePath = base_path($this->commandData->fieldsFile);
             }
             if (!file_exists($filePath)) {
                 $this->commandData->commandObj->error("Fields file not found");
                 exit;
             }
             $fileContents = $fileHelper->getFileContents($filePath);
             $fields = json_decode($fileContents, true);
             $this->commandData->inputFields = GeneratorUtils::validateFieldsFile($fields);
         } catch (Exception $e) {
             $this->commandData->commandObj->error($e->getMessage());
             exit;
         }
     } else {
         $this->commandData->inputFields = $this->commandData->getInputFields();
     }
 }