private function generateUpdateRequest()
 {
     $templateData = TemplateUtil::getTemplate('scaffold.request.update_request', 'laravel-generator');
     $templateData = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $templateData);
     FileUtil::createFile($this->path, $this->updateFileName, $templateData);
     $this->commandData->commandComment("\nUpdate Request created: ");
     $this->commandData->commandInfo($this->updateFileName);
 }
 public function generate()
 {
     $templateData = TemplateUtil::getTemplate('api.test.api_test', 'laravel-generator');
     $templateData = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $templateData);
     FileUtil::createFile($this->path, $this->fileName, $templateData);
     $this->commandData->commandObj->comment("\nApiTest created: ");
     $this->commandData->commandObj->info($this->fileName);
 }
 private function updateRoutes()
 {
     $path = config('infyom.laravel_generator.path.routes', app_path('Http/routes.php'));
     $routeContents = file_get_contents($path);
     $routesTemplate = TemplateUtil::getTemplate('routes.auth', 'laravel-generator');
     $routeContents .= "\n\n" . $routesTemplate;
     file_put_contents($path, $routeContents);
     $this->comment("\nRoutes added");
 }
 public function __construct(CommandData $commandData)
 {
     $this->commandData = $commandData;
     $this->path = config('infyom.laravel_generator.path.views', base_path('resources/views/')) . $commandData->getAddOn('menu.menu_file');
     $this->templateType = config('infyom.laravel_generator.templates', 'core-templates');
     $this->menuContents = file_get_contents($this->path);
     $this->menuTemplate = TemplateUtil::getTemplate('scaffold.layouts.menu_template', $this->templateType);
     $this->menuTemplate = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $this->menuTemplate);
 }
 private function generateUpdateRequest()
 {
     $templateData = TemplateUtil::getTemplate('api.request.update_request', 'laravel-generator');
     $templateData = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $templateData);
     $fileName = 'Update' . $this->commandData->modelName . 'APIRequest.php';
     FileUtil::createFile($this->path, $fileName, $templateData);
     $this->commandData->commandComment("\nUpdate Request created: ");
     $this->commandData->commandInfo($fileName);
 }
 function generate()
 {
     $templateData = TemplateUtil::getTemplate("api.test.api_test", "laravel-generator");
     $templateData = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $templateData);
     $fileName = $this->commandData->modelName . "ApiTest.php";
     FileUtil::createFile($this->path, $fileName, $templateData);
     $this->commandData->commandObj->comment("\nApiTest created: ");
     $this->commandData->commandObj->info($fileName);
 }
 public function generate()
 {
     $routeContents = file_get_contents($this->path);
     $routesTemplate = TemplateUtil::getTemplate('scaffold.routes.routes', 'laravel-generator');
     $routesTemplate = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $routesTemplate);
     $routeContents .= "\n\n" . $routesTemplate;
     file_put_contents($this->path, $routeContents);
     $this->commandData->commandComment("\n" . $this->commandData->modelNames['camelPlural'] . ' routes added.');
 }
 /**
  * Initialize routes group based on route integration.
  */
 private function initAPIRoutes()
 {
     $path = config('infyom.laravel_generator.path.routes', app_path('Http/routes.php'));
     $routeContents = file_get_contents($path);
     $template = 'api.routes.api_routes_group';
     $templateData = TemplateUtil::getTemplate($template, 'laravel-generator');
     $templateData = $this->fillTemplate($templateData);
     file_put_contents($path, $routeContents . "\n\n" . $templateData);
     $this->comment("\nAPI group added to routes.php");
 }
 public static function generateSwagger($fields, $fillables, $variables)
 {
     $template = TemplateUtil::getTemplate("model.model", 'swagger-generator');
     $templateData = TemplateUtil::fillTemplate($variables, $template);
     $templateData = str_replace('$REQUIRED_FIELDS$', implode(", ", $fillables), $templateData);
     $propertyTemplate = TemplateUtil::getTemplate("model.property", 'swagger-generator');
     $properties = self::preparePropertyFields($propertyTemplate, $fields);
     $templateData = str_replace('$PROPERTIES$', implode(",\n", $properties), $templateData);
     return $templateData;
 }
 public function generate()
 {
     $templateData = TemplateUtil::getTemplate('migration', 'laravel-generator');
     $templateData = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $templateData);
     $templateData = str_replace('$FIELDS$', $this->generateFields(), $templateData);
     $tableName = $this->commandData->dynamicVars['$TABLE_NAME$'];
     $fileName = date('Y_m_d_His') . '_' . 'create_' . $tableName . '_table.php';
     FileUtil::createFile($this->path, $fileName, $templateData);
     $this->commandData->commandComment("\nMigration created: ");
     $this->commandData->commandInfo($fileName);
 }
 public function generateSwagger($templateData)
 {
     $fieldTypes = SwaggerGenerator::generateTypes($this->commandData->inputFields);
     $template = TemplateUtil::getTemplate("model.model", 'swagger-generator');
     $template = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $template);
     $template = str_replace('$REQUIRED_FIELDS$', implode(", ", $this->generateRequiredFields()), $template);
     $propertyTemplate = TemplateUtil::getTemplate("model.property", 'swagger-generator');
     $properties = SwaggerGenerator::preparePropertyFields($propertyTemplate, $fieldTypes);
     $template = str_replace('$PROPERTIES$', implode(",\n", $properties), $template);
     $templateData = str_replace('$DOCS$', $template, $templateData);
     return $templateData;
 }
 public function __construct(CommandData $commandData)
 {
     $this->commandData = $commandData;
     $this->path = $commandData->config->pathRoutes;
     $this->routeContents = file_get_contents($this->path);
     if (!empty($this->commandData->config->prefixes['route'])) {
         $this->routesTemplate = TemplateUtil::getTemplate('scaffold.routes.prefix_routes', 'laravel-generator');
     } else {
         $this->routesTemplate = TemplateUtil::getTemplate('scaffold.routes.routes', 'laravel-generator');
     }
     $this->routesTemplate = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $this->routesTemplate);
 }
 public function generate()
 {
     $templateData = TemplateUtil::getTemplate('scaffold.controller.controller', 'laravel-generator');
     $templateData = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $templateData);
     $paginate = $this->commandData->getOption('paginate');
     if ($paginate) {
         $templateData = str_replace('$RENDER_TYPE$', 'paginate(' . $paginate . ')', $templateData);
     } else {
         $templateData = str_replace('$RENDER_TYPE$', 'all()', $templateData);
     }
     $fileName = $this->commandData->modelName . 'Controller.php';
     FileUtil::createFile($this->path, $fileName, $templateData);
     $this->commandData->commandComment("\nController created: ");
     $this->commandData->commandInfo($fileName);
 }
 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);
 }
 public function generate()
 {
     $templateData = TemplateUtil::getTemplate('repository', 'laravel-generator');
     $templateData = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $templateData);
     $fillables = [];
     foreach ($this->commandData->inputFields as $field) {
         if ($field['searchable']) {
             $fillables[] = '"' . $field['fieldName'] . '"';
         }
     }
     $templateData = str_replace('$FIELDS$', implode(",\n\t\t", $fillables), $templateData);
     $fileName = $this->commandData->modelName . 'Repository.php';
     FileUtil::createFile($this->path, $fileName, $templateData);
     $this->commandData->commandComment("\nRepository created: ");
     $this->commandData->commandInfo($fileName);
 }
 private function fillDocs($templateData)
 {
     $methods = ['controller', 'index', 'store', 'store', 'show', 'update', 'destroy'];
     if ($this->commandData->getAddOn('swagger')) {
         $templatePrefix = 'controller';
         $templateType = 'swagger-generator';
     } else {
         $templatePrefix = 'api.docs.controller';
         $templateType = 'laravel-generator';
     }
     foreach ($methods as $method) {
         $key = '$DOC_' . strtoupper($method) . '$';
         $docTemplate = TemplateUtil::getTemplate($templatePrefix . '.' . $method, $templateType);
         $docTemplate = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $docTemplate);
         $templateData = str_replace($key, $docTemplate, $templateData);
     }
     return $templateData;
 }
 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 publishHomeController()
 {
     $templateData = TemplateUtil::getTemplate('home_controller', 'laravel-generator');
     $templateData = $this->fillTemplate($templateData);
     $controllerPath = config('infyom.laravel_generator.path.controller', app_path('Http/Controllers/'));
     $fileName = 'HomeController.php';
     if (file_exists($controllerPath . $fileName) && !$this->confirmOverwrite($fileName)) {
         return;
     }
     FileUtil::createFile($controllerPath, $fileName, $templateData);
     $this->info('HomeController created');
 }
 private function generateUpdate()
 {
     $templateData = TemplateUtil::getTemplate('scaffold.views.edit', $this->templateType);
     $templateData = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $templateData);
     FileUtil::createFile($this->path, 'edit.blade.php', $templateData);
     $this->commandData->commandInfo('edit.blade.php created');
 }
 private function generateShowFields()
 {
     $fieldTemplate = TemplateUtil::getTemplate('scaffold.views.show_field', $this->templateType);
     $fieldsStr = '';
     foreach ($this->commandData->inputFields as $field) {
         $singleFieldStr = str_replace('$FIELD_NAME_TITLE$', Str::title(str_replace('_', ' ', $field['fieldName'])), $fieldTemplate);
         $singleFieldStr = str_replace('$FIELD_NAME$', $field['fieldName'], $singleFieldStr);
         $singleFieldStr = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $singleFieldStr);
         $fieldsStr .= $singleFieldStr . "\n\n";
     }
     FileUtil::createFile($this->path, 'show_fields.blade.php', $fieldsStr);
     $this->commandData->commandInfo('show_fields.blade.php created');
 }
 private function fillTemplate($templateData)
 {
     $templateData = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $templateData);
     $templateData = str_replace('$FIELDS$', implode(",\n\t\t\t", $this->generateFields()), $templateData);
     return $templateData;
 }
 private function fillTemplate($templateData)
 {
     $templateData = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $templateData);
     return $templateData;
 }