private function generateScaffoldRoutes()
 {
     $routeContents = $this->commandData->fileHelper->getFileContents($this->path);
     $templateData = $this->commandData->templatesHelper->getTemplate('scaffold_routes', 'routes');
     $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData);
     $routeContents .= "\n\n" . $templateData;
     $this->commandData->fileHelper->writeFile($this->path, $routeContents);
     $this->commandData->commandObj->comment("\nroutes.php modified:");
     $this->commandData->commandObj->info('"' . $this->commandData->modelNamePluralCamel . '" route added.');
 }
 private function generateUpdateRequest()
 {
     $templateData = $this->commandData->templatesHelper->getTemplate('UpdateRequest', 'scaffold/requests');
     $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData);
     $fileName = 'Update' . $this->commandData->modelName . 'Request.php';
     $path = $this->path . $fileName;
     $this->commandData->fileHelper->writeFile($path, $templateData);
     $this->commandData->commandObj->comment("\nUpdate Request created: ");
     $this->commandData->commandObj->info($fileName);
 }
 public function generate()
 {
     $templateData = $this->commandData->templatesHelper->getTemplate('Migration', 'common');
     $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData);
     $templateData = str_replace('$FIELDS$', $this->generateFieldsStr(), $templateData);
     $fileName = date('Y_m_d_His') . '_' . 'create_' . $this->commandData->modelNamePluralCamel . '_table.php';
     $path = $this->path . $fileName;
     $this->commandData->fileHelper->writeFile($path, $templateData);
     $this->commandData->commandObj->comment("\nMigration created: ");
     $this->commandData->commandObj->info($fileName);
 }
 public function generate()
 {
     $templateData = $this->commandData->templatesHelper->getTemplate('Controller', 'api');
     $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData);
     $fileName = $this->commandData->modelName . 'APIController.php';
     if (!file_exists($this->path)) {
         mkdir($this->path, 0755, true);
     }
     $path = $this->path . $fileName;
     $this->commandData->fileHelper->writeFile($path, $templateData);
     $this->commandData->commandObj->comment("\nAPI Controller created: ");
     $this->commandData->commandObj->info($fileName);
 }
 public function generate()
 {
     $templateData = $this->commandData->templatesHelper->getTemplate('Interface', 'common');
     $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData);
     $fileName = 'I' . $this->commandData->modelName . 'Repository.php';
     if (!file_exists($this->path)) {
         mkdir($this->path, 0755, true);
     }
     $path = $this->path . $fileName;
     $this->commandData->fileHelper->writeFile($path, $templateData);
     $this->commandData->commandObj->comment("\nInterface created: ");
     $this->commandData->commandObj->info($fileName);
 }
 public function generate()
 {
     $templateData = $this->commandData->templatesHelper->getTemplate('Validator', 'common');
     $templateData = str_replace('$RULES$', implode(",\n        ", $this->generateRules()), $templateData);
     $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData);
     $fileName = $this->commandData->modelName . 'Validator.php';
     if (!file_exists($this->path)) {
         mkdir($this->path, 0755, true);
     }
     $path = $this->path . $fileName;
     $this->commandData->fileHelper->writeFile($path, $templateData);
     $this->commandData->commandObj->comment("\nValidato created: ");
     $this->commandData->commandObj->info($fileName);
 }
 public function generate()
 {
     $templateData = $this->commandData->templatesHelper->getTemplate('Controller', 'scaffold');
     $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData);
     if ($this->commandData->paginate) {
         $templateData = str_replace('$RENDER_TYPE$', 'paginate(' . $this->commandData->paginate . ')', $templateData);
     } else {
         $templateData = str_replace('$RENDER_TYPE$', 'all()', $templateData);
     }
     $fileName = $this->commandData->modelName . 'Controller.php';
     $path = $this->path . $fileName;
     $this->commandData->fileHelper->writeFile($path, $templateData);
     $this->commandData->commandObj->comment("\nController created: ");
     $this->commandData->commandObj->info($fileName);
 }
 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 = str_replace('$RELATIONS$', $this->generateRelations(), $templateData);
     $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData);
     $fillables = [];
     foreach ($this->commandData->inputFields as $field) {
         $fillables[] = '"' . $field['fieldName'] . '"';
     }
     $templateData = str_replace('$FIELDS$', implode(",\n\t\t", $fillables), $templateData);
     $templateData = str_replace('$RULES$', implode(",\n\t\t", $this->generateRules()), $templateData);
     $templateData = str_replace('$CAST$', implode(",\n\t\t", $this->generateCasts()), $templateData);
     $templateData = str_replace('$DISPLAY_ATTRIBUTE$', $this->getDisplayAttr(), $templateData);
     return $templateData;
 }
 private function generateEdit()
 {
     $templateData = $this->commandData->templatesHelper->getTemplate('edit.blade', $this->viewsPath);
     $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData);
     $fileName = 'edit.blade.php';
     $path = $this->path . $fileName;
     $this->commandData->fileHelper->writeFile($path, $templateData);
     $this->commandData->commandObj->info('edit.blade.php created');
 }
 /**
  * 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);
 }