public function handle() { $this->commandData->modelName = $this->argument('model'); $this->commandData->useSoftDelete = $this->option('softDelete'); $this->commandData->useSearch = $this->option('search'); $this->commandData->fieldsFile = $this->option('fieldsFile'); $this->commandData->initVariables(); if ($this->commandData->fieldsFile) { $fileHelper = new FileHelper(); try { if (file_exists($this->commandData->fieldsFile)) { $filePath = $this->commandData->fieldsFile; } else { $filePath = base_path($this->commandData->fieldsFile); } if (!file_exists($filePath)) { $this->commandData->commandObj->error("Fields file not found"); exit; } $fileContents = $fileHelper->getFileContents($filePath); $fields = json_decode($fileContents, true); $this->commandData->inputFields = GeneratorUtils::validateFieldsFile($fields); } catch (Exception $e) { $this->commandData->commandObj->error($e->getMessage()); exit; } } else { $this->commandData->inputFields = $this->commandData->getInputFields(); } }
/** * Execute the command. * * @return void */ public function handle() { $namespace = $this->argument('namespace'); $templateHelper = new TemplatesHelper(); $templateData = $templateHelper->getTemplate('AppBaseController', 'Controller'); $templateData = str_replace('$$BASE_NAMESPACE$$', $namespace, $templateData); $fileName = "AppBaseController.php"; $filePath = __DIR__ . "/../../Controller/"; $fileHelper = new FileHelper(); $fileHelper->writeFile($filePath . $fileName, $templateData); $this->comment('AppBaseController generated'); $this->info($fileName); }