public function fillTemplate($templateData)
 {
     $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData);
     $fieldTypes = $this->commandData->getSwaggerTypes();
     $fieldTypes = array_merge($fieldTypes, [['name' => "limit", 'type' => "integer", "description" => "Limit the number of results returned"], ['name' => "offset", 'type' => "integer", "description" => "Records from give Offset"], ['name' => "sort", 'type' => "string", "description" => "Sort records by given field"]]);
     $templateData = str_replace('$PARAMETERS$', implode(",\n", $this->generateSwagger($fieldTypes)), $templateData);
     return $templateData;
 }
 public function handle()
 {
     $this->commandData->modelName = $this->argument('model');
     $this->commandData->useSoftDelete = $this->option('softDelete');
     $this->commandData->fieldsFile = $this->option('fieldsFile');
     $this->commandData->paginate = $this->option('paginate');
     $this->commandData->tableName = $this->option('tableName');
     $this->commandData->skipMigration = $this->option('skipMigration');
     $this->commandData->fromTable = $this->option('fromTable');
     $this->commandData->rememberToken = $this->option('rememberToken');
     if ($this->commandData->fromTable) {
         if (!$this->commandData->tableName) {
             $this->error('tableName required with fromTable option.');
             exit;
         }
     }
     if ($this->commandData->paginate <= 0) {
         $this->commandData->paginate = 10;
     }
     $this->commandData->initVariables();
     $this->commandData->addDynamicVariable('$NAMESPACE_APP$', $this->getLaravel()->getNamespace());
     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;
         }
     } elseif ($this->commandData->fromTable) {
         $tableFieldsGenerator = new TableFieldsGenerator($this->commandData->tableName);
         $this->commandData->inputFields = $tableFieldsGenerator->generateFieldsFromTable();
     } else {
         $this->commandData->inputFields = $this->commandData->getInputFields();
     }
 }
 private function fillTemplate($templateData)
 {
     if (!$this->commandData->useSoftDelete) {
         $templateData = str_replace('$SOFT_DELETE_IMPORT$', '', $templateData);
         $templateData = str_replace('$SOFT_DELETE$', '', $templateData);
         $templateData = str_replace('$SOFT_DELETE_DATES$', '', $templateData);
     }
     $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData);
     $fillables = [];
     foreach ($this->commandData->inputFields as $field) {
         if (in_array($field['fieldName'], $this->commandData->excludedFields) or $field['fieldName'] == "id") {
             continue;
         }
         $fillables[] = '"' . $field['fieldName'] . '"';
     }
     $templateData = str_replace('$FIELDS$', implode(",\n\t\t", $fillables), $templateData);
     $templateData = str_replace('$RULES$', implode(",\n\t\t", $this->generateRules()), $templateData);
     $castFields = $this->generateCasts();
     $templateData = str_replace('$CAST$', implode(",\n\t\t", $castFields), $templateData);
     $fieldTypes = $this->commandData->getSwaggerTypes();
     $templateData = str_replace('$SWAGGER_DOCS$', $this->generateSwagger($fieldTypes, $fillables), $templateData);
     return $templateData;
 }
 /**
  * Publishes base controller.
  */
 private function publishAppBaseController()
 {
     $templateHelper = new TemplatesHelper();
     $templateData = $templateHelper->getTemplate('AppBaseController', 'controller');
     $templateData = GeneratorUtils::fillTemplate(CommandData::getConfigDynamicVariables(), $templateData);
     $fileName = 'AppBaseController.php';
     $filePath = Config::get('generator.path_controller', app_path('Http/Controllers/'));
     $fileHelper = new FileHelper();
     $fileHelper->writeFile($filePath . $fileName, $templateData);
     $this->comment('AppBaseController generated');
     $this->info($fileName);
 }