private function generateFields()
 {
     $fields = [];
     foreach ($this->commandData->inputFields as $field) {
         if ($field['fieldName'] == 'created_at' or $field['fieldName'] == 'updated_at') {
             continue;
         }
         $fields[] = SchemaUtil::createField($field);
     }
     $fields[] = '$table->timestamps();';
     if ($this->commandData->getOption('softDelete')) {
         $fields[] = '$table->softDeletes();';
     }
     return implode(infy_nl_tab(1, 3), $fields);
 }
 public function generate()
 {
     $templateData = TemplateUtil::getTemplate('repository', 'laravel-generator');
     $templateData = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $templateData);
     $searchables = [];
     foreach ($this->commandData->inputFields as $field) {
         if ($field['searchable']) {
             $searchables[] = "'" . $field['fieldName'] . "'";
         }
     }
     $templateData = str_replace('$FIELDS$', implode(',' . infy_nl_tab(1, 2), $searchables), $templateData);
     FileUtil::createFile($this->path, $this->fileName, $templateData);
     $this->commandData->commandComment("\nRepository created: ");
     $this->commandData->commandInfo($this->fileName);
 }
 private function generateDataTable()
 {
     $templateData = TemplateUtil::getTemplate('scaffold.datatable', 'laravel-generator');
     $templateData = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $templateData);
     $headerFieldTemplate = TemplateUtil::getTemplate('scaffold.views.datatable_column', $this->templateType);
     $headerFields = [];
     foreach ($this->commandData->inputFields as $field) {
         if (!$field['inIndex']) {
             continue;
         }
         $headerFields[] = $fieldTemplate = TemplateUtil::fillTemplateWithFieldData($this->commandData->dynamicVars, $this->commandData->fieldNamesMapping, $headerFieldTemplate, $field);
     }
     $path = $this->commandData->config->pathDataTables;
     $fileName = $this->commandData->modelName . 'DataTable.php';
     $fields = implode(',' . infy_nl_tab(1, 3), $headerFields);
     $templateData = str_replace('$DATATABLE_COLUMNS$', $fields, $templateData);
     FileUtil::createFile($path, $fileName, $templateData);
     $this->commandData->commandComment("\n{$fileName} created: ");
     $this->commandData->commandInfo($fileName);
 }
 private function generateBladeTableBody()
 {
     $templateData = TemplateUtil::getTemplate('scaffold.views.blade_table_body', $this->templateType);
     $templateData = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $templateData);
     $templateData = str_replace('$FIELD_HEADERS$', $this->generateTableHeaderFields(), $templateData);
     $cellFieldTemplate = TemplateUtil::getTemplate('scaffold.views.table_cell', $this->templateType);
     $tableBodyFields = [];
     foreach ($this->commandData->inputFields as $field) {
         if (!$field['inIndex']) {
             continue;
         }
         $tableBodyFields[] = TemplateUtil::fillTemplateWithFieldData($this->commandData->dynamicVars, $this->commandData->fieldNamesMapping, $cellFieldTemplate, $field);
     }
     $tableBodyFields = implode(infy_nl_tab(1, 3), $tableBodyFields);
     return str_replace('$FIELD_BODY$', $tableBodyFields, $templateData);
 }
 private function fillTimestamps($templateData)
 {
     $timestamps = TableFieldsGenerator::getTimestampFieldNames();
     $replace = '';
     if ($this->commandData->getOption('fromTable')) {
         if (empty($timestamps)) {
             $replace = infy_nl_tab() . "public \$timestamps = false;\n";
         } else {
             list($created_at, $updated_at) = collect($timestamps)->map(function ($field) {
                 return !empty($field) ? "'{$field}'" : 'null';
             });
             $replace .= infy_nl_tab() . "const CREATED_AT = {$created_at};";
             $replace .= infy_nl_tab() . "const UPDATED_AT = {$updated_at};\n";
         }
     }
     return str_replace('$TIMESTAMPS$', $replace, $templateData);
 }
 private function fillTemplate($templateData)
 {
     $templateData = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $templateData);
     $templateData = str_replace('$FIELDS$', implode(',' . infy_nl_tab(1, 3), $this->generateFields()), $templateData);
     return $templateData;
 }