public function generate() { $templateData = $this->commandData->templatesHelper->getTemplate('Controller', 'api'); if ($this->commandData->pointerModel) { $pointerRelationship = []; foreach ($this->commandData->inputFields as $field) { if ($field['type'] == 'pointer') { $arr = explode(',', $field['typeOptions']); if (count($arr) > 0) { $modelName = $arr[0]; $pointerRelationship[] = "'" . Str::camel($modelName) . "'"; } } } $templateData = str_replace('$POINTER_MODELS_RELATIONSHIP$', "with([" . implode(", ", $pointerRelationship) . "])->", $templateData); } else { $templateData = str_replace('$POINTER_MODELS_RELATIONSHIP$', '', $templateData); } $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); }
private function generateAppBind() { $appBindContents = $this->commandData->fileHelper->getFileContents($this->path); $templateData = $this->commandData->templatesHelper->getTemplate("AppBind", "common"); $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData); $appBindContents .= "\n\n" . $templateData; $this->commandData->fileHelper->writeFile($this->path, $appBindContents); $this->commandData->commandObj->comment("\nregister_app_bind.php modified:"); $this->commandData->commandObj->info("\"" . $this->commandData->modelNamePluralCamel . "\" \$this->app->bind() added."); }
private function generateScaffoldBreadcrumbs() { $breadcrumbsContents = $this->commandData->fileHelper->getFileContents($this->path); $templateData = $this->commandData->templatesHelper->getTemplate("breadcrumbs", "scaffold"); $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData); $breadcrumbsContents .= "\n\n" . $templateData; $this->commandData->fileHelper->writeFile($this->path, $breadcrumbsContents); $this->commandData->commandObj->comment("\nbreadcrumbs.php modified:"); $this->commandData->commandObj->info("\"" . $this->commandData->modelNamePluralCamel . "\" breadcrumb 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); }
private function generateScaffoldRoutes() { $routeContents = $this->commandData->fileHelper->getFileContents($this->scaffoldPath); $templateData = $this->commandData->templatesHelper->getTemplate('scaffold_route', 'routes'); $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData); $routeContents .= "\n\n" . $templateData; $this->commandData->fileHelper->writeFile($this->scaffoldPath, $routeContents); $this->commandData->commandObj->comment("\nscaffold_routes.php modified:"); $this->commandData->commandObj->info('"' . $this->commandData->modelNamePluralCamel . '" route added.'); }
private function generateMenu() { $menuContents = $this->commandData->fileHelper->getFileContents($this->path); $templateData = $this->commandData->templatesHelper->getTemplate('scaffold_menus', 'menus'); $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData); $menuContents .= "\n\n" . $templateData; $this->commandData->fileHelper->writeFile($this->path, $menuContents); $this->commandData->commandObj->comment("\nmenus.blade.php modified:"); $this->commandData->commandObj->info('"' . $this->commandData->modelNamePluralCamel . '" menu added.'); }
private function generateShow() { $templateData = $this->commandData->templatesHelper->getTemplate('show.blade', $this->viewsPath); $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData); $fileName = 'show.blade.php'; $path = $this->path . $fileName; $this->commandData->fileHelper->writeFile($path, $templateData); \Log::info($fileName . ' Was Generated'); $this->commandData->commandObj->info('show.blade.php created'); }
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', 'scaffold'); $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData); $fileName = $this->commandData->modelName . 'Controller.php'; $path = $this->path . $fileName; $this->commandData->fileHelper->writeFile($path, $templateData); $this->commandData->commandObj->comment("\nLive Controller created: "); \Log::info('' . $fileName . ' Was Generated'); $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); }
function generate() { $templateData = $this->commandData->templatesHelper->getTemplate("FractalPresenter", "common"); $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData); $fileName = $this->commandData->modelName . "APIPresenter.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("\nAPIPresenter created: "); $this->commandData->commandObj->info($fileName); }
public function generate() { $templateData = $this->commandData->templatesHelper->getTemplate('Repository', 'common'); $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData); $fileName = $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("\nRepository created: "); \Log::info('' . $fileName . ' Was Generated'); $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 = 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); return $templateData; }
function generate() { $templateData = $this->commandData->templatesHelper->getTemplate("Repository", "common"); $fillables = []; foreach ($this->commandData->inputFields as $field) { $fillables[] = '"' . $field['fieldName'] . '" => ' . '"like"'; } $templateData = str_replace('$FIELDS$', implode(",\n\t\t", $fillables), $templateData); $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData); $fileName = $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("\nRepository created: "); $this->commandData->commandObj->info($fileName); }
function generate() { $templateData = $this->commandData->templatesHelper->getTemplate("FractalTransformer", "common"); $transformer_fields = []; foreach ($this->commandData->inputFields as $field) { if (!in_array($field['fieldName'], ['id', 'created_at', 'updated_at'])) { $transformer_fields[] = "'" . $field['fieldName'] . "' => \$model->" . $field['fieldName'] . ","; } } $templateData = str_replace('$FIELDS$', implode("\n\t\t\t", $transformer_fields), $templateData); $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData); $fileName = $this->commandData->modelName . "APIPresenterTransformer.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("\nPresenterTransformer created: "); $this->commandData->commandObj->info($fileName); }
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); }
private function generateEdit() { $langStr = "'edit_model'=>'Edit " . $this->commandData->modelName . "',\n"; $templateData = $this->commandData->templatesHelper->getTemplate('edit.blade', $this->viewsPath); $templateLang = $this->commandData->templatesHelper->getTemplate('edit', $this->langsPath); $templateLang = str_replace('$EDIT_LANG$', $langStr, $templateLang); $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData); $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData); $fileName = 'edit.blade.php'; $path = $this->path . $fileName; $pathLang = $this->path_lang . str_replace('.blade', '', $fileName); $this->commandData->fileHelper->writeFile($path, $templateData); $this->commandData->commandObj->info('edit.blade.php created'); $this->commandData->fileHelper->writeFile($pathLang, $templateLang); $this->commandData->commandObj->info('edit.php created'); }