public function rollback() { if (Str::contains($this->menuContents, $this->menuTemplate)) { file_put_contents($this->path, str_replace($this->menuTemplate, '', $this->menuContents)); $this->commandData->commandComment('menu deleted'); } }
public function rollback() { if (Str::contains($this->routeContents, $this->routesTemplate)) { $this->routeContents = str_replace($this->routesTemplate, '', $this->routeContents); file_put_contents($this->path, $this->routeContents); $this->commandData->commandComment('scaffold routes deleted'); } }
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.'); }
private function generateUpdateRequest() { $templateData = TemplateUtil::getTemplate('scaffold.request.update_request', 'laravel-generator'); $templateData = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $templateData); $fileName = 'Update' . $this->commandData->modelName . 'Request.php'; FileUtil::createFile($this->path, $fileName, $templateData); $this->commandData->commandComment("\nUpdate Request created: "); $this->commandData->commandInfo($fileName); }
public function generate() { $templateData = TemplateUtil::getTemplate('model', 'laravel-generator'); $templateData = $this->fillTemplate($templateData); $fileName = $this->commandData->modelName . '.php'; FileUtil::createFile($this->path, $fileName, $templateData); $this->commandData->commandComment("\nModel created: "); $this->commandData->commandInfo($fileName); }
public function rollback() { if ($this->rollbackFile($this->path, $this->createFileName)) { $this->commandData->commandComment('Create API Request file deleted: ' . $this->createFileName); } if ($this->rollbackFile($this->path, $this->updateFileName)) { $this->commandData->commandComment('Update API Request file deleted: ' . $this->updateFileName); } }
public function generate() { $templateData = TemplateUtil::getTemplate('api.controller.api_controller', 'laravel-generator'); $templateData = TemplateUtil::fillTemplate($this->commandData->dynamicVars, $templateData); $templateData = $this->fillDocs($templateData); $fileName = $this->commandData->modelName . 'APIController.php'; FileUtil::createFile($this->path, $fileName, $templateData); $this->commandData->commandComment("\nAPI Controller created: "); $this->commandData->commandInfo($fileName); }
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 generate() { if (!file_exists($this->path)) { mkdir($this->path, 0755, true); } $this->commandData->commandComment("\nGenerating Views..."); $this->generateTable(); $this->generateIndex(); $this->generateFields(); $this->generateCreate(); $this->generateUpdate(); $this->commandData->commandComment("Views created: "); }
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); $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 saveSchemaFile() { $fileFields = []; foreach ($this->commandData->inputFields as $field) { $fileFields[] = ['fieldInput' => $field['fieldInput'], 'htmlType' => $field['htmlType'], 'validations' => $field['validations'], 'searchable' => $field['searchable']]; } $path = config('infyom.laravel_generator.path.schema_files', base_path('resources/model_schemas/')); $fileName = $this->commandData->modelName . ".json"; if (file_exists($path . $fileName)) { if (!$this->confirm("model file " . $fileName . " already exist. Do you want to overwrite it? [y|N]", false)) { return; } } FileUtil::createFile($path, $fileName, json_encode($fileFields, JSON_PRETTY_PRINT)); $this->commandData->commandComment("\nSchema File saved: "); $this->commandData->commandInfo($fileName); }
public function rollback() { $files = ['table.blade.php', 'index.blade.php', 'fields.blade.php', 'create.blade.php', 'edit.blade.php', 'show.blade.php', 'show_fields.blade.php']; foreach ($files as $file) { if ($this->rollbackFile($this->path, $file)) { $this->commandData->commandComment($file . ' file deleted'); } } }
public function rollback() { $fileName = 'create_' . $this->commandData->config->tableName . '_table.php'; /** @var SplFileInfo $allFiles */ $allFiles = File::allFiles($this->path); $files = []; foreach ($allFiles as $file) { $files[] = $file->getFilename(); } $files = array_reverse($files); foreach ($files as $file) { if (Str::contains($file, $fileName)) { if ($this->rollbackFile($this->path, $file)) { $this->commandData->commandComment('Migration file deleted: ' . $file); } break; } } }
private function saveSchemaFile() { $fileFields = []; foreach ($this->commandData->inputFields as $field) { $fileFields[] = ['fieldInput' => $field['fieldInput'], 'htmlType' => $field['htmlType'], 'validations' => $field['validations'], 'searchable' => $field['searchable'], 'fillable' => $field['fillable'], 'primary' => $field['primary'], 'inForm' => $field['inForm'], 'inIndex' => $field['inIndex']]; } $path = config('infyom.laravel_generator.path.schema_files', base_path('resources/model_schemas/')); $fileName = $this->commandData->modelName . '.json'; if (file_exists($path . $fileName) && !$this->confirmOverwrite($fileName)) { return; } FileUtil::createFile($path, $fileName, json_encode($fileFields, JSON_PRETTY_PRINT)); $this->commandData->commandComment("\nSchema File saved: "); $this->commandData->commandInfo($fileName); }
public function rollback() { if ($this->rollbackFile($this->path, $this->fileName)) { $this->commandData->commandComment('Model file deleted: ' . $this->fileName); } }
public function rollback() { if (Str::contains($this->menuContents, $this->menuTemplate)) { $this->commandData->commandComment('menu deleted'); } }