private function generateFields() { $fieldTemplate = ''; $fieldsStr = ''; $fieldsLang = ''; foreach ($this->commandData->inputFields as $field) { $fieldsLang .= "'" . $field['fieldName'] . "'=>'" . Str::title(str_replace('_', ' ', $field['fieldName'])) . "',\n"; switch ($field['type']) { case 'text': $fieldTemplate = $this->commandData->templatesHelper->getTemplate('field.blade', $this->viewsPath); $fieldsStr .= FormFieldsGenerator::text($fieldTemplate, $field) . "\n\n"; break; case 'textarea': $fieldTemplate = $this->commandData->templatesHelper->getTemplate('field.blade', $this->viewsPath); $fieldsStr .= FormFieldsGenerator::textarea($fieldTemplate, $field) . "\n\n"; break; case 'password': $fieldTemplate = $this->commandData->templatesHelper->getTemplate('field.blade', $this->viewsPath); $fieldsStr .= FormFieldsGenerator::password($fieldTemplate, $field) . "\n\n"; break; case 'email': $fieldTemplate = $this->commandData->templatesHelper->getTemplate('field.blade', $this->viewsPath); $fieldsStr .= FormFieldsGenerator::email($fieldTemplate, $field) . "\n\n"; break; case 'file': $fieldTemplate = $this->commandData->templatesHelper->getTemplate('file.blade', $this->viewsPath); $fieldsStr .= FormFieldsGenerator::file($fieldTemplate, $field) . "\n\n"; break; case 'checkbox': $fieldTemplate = $this->commandData->templatesHelper->getTemplate('checkbox.blade', $this->viewsPath); $fieldsStr .= FormFieldsGenerator::checkbox($fieldTemplate, $field) . "\n\n"; break; case 'radio': $fieldTemplate = $this->commandData->templatesHelper->getTemplate('radio.blade', $this->viewsPath); $fieldsStr .= FormFieldsGenerator::radio($fieldTemplate, $field) . "\n\n"; break; case 'number': $fieldTemplate = $this->commandData->templatesHelper->getTemplate('field.blade', $this->viewsPath); $fieldsStr .= FormFieldsGenerator::number($fieldTemplate, $field) . "\n\n"; break; case 'date': $fieldTemplate = $this->commandData->templatesHelper->getTemplate('date.blade', $this->viewsPath); $fieldsStr .= FormFieldsGenerator::date($fieldTemplate, $field) . "\n\n"; break; case 'select': $fieldTemplate = $this->commandData->templatesHelper->getTemplate('field.blade', $this->viewsPath); $fieldsStr .= FormFieldsGenerator::select($fieldTemplate, $field) . "\n\n"; break; case 'pointer': $fieldTemplate = $this->commandData->templatesHelper->getTemplate('pointer.blade', $this->viewsPath); $fieldsStr .= FormFieldsGenerator::pointer($fieldTemplate, $field) . "\n\n"; break; } } $fieldsLang .= "'save'=>'Save',\n"; $fieldsLang .= "'cancel'=>'Cancel',\n"; $templateData = $this->commandData->templatesHelper->getTemplate('fields.blade', $this->viewsPath); $templateLang = $this->commandData->templatesHelper->getTemplate('fields', $this->langsPath); $templateData = str_replace('$FIELDS$', $fieldsStr, $templateData); $templateLang = str_replace('$FIELDS_LANG$', $fieldsLang, $templateLang); $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData); $templateLang = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateLang); $fileName = 'fields.blade.php'; $path = $this->path . $fileName; $pathLang = $this->path_lang . str_replace('.blade', '', $fileName); $this->commandData->fileHelper->writeFile($path, $templateData); $this->commandData->commandObj->info('field.blade.php created'); $this->commandData->fileHelper->writeFile($pathLang, $templateLang); $this->commandData->commandObj->info('fields.php created'); }