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);
}
/** * Execute the command. * * @return void */ public function handle() { parent::handle(); $this->initAPIGeneratorCommandData(); if (!$this->commandData->options['fromTable']) { $migrationGenerator = new MigrationGenerator($this->commandData); $migrationGenerator->generate(); } $modelGenerator = new ModelGenerator($this->commandData); $modelGenerator->generate(); $repositoryGenerator = new RepositoryGenerator($this->commandData); $repositoryGenerator->generate(); $controllerGenerator = new APIControllerGenerator($this->commandData); $controllerGenerator->generate(); $requestGenerator = new APIRequestGenerator($this->commandData); $requestGenerator->generate(); $routesGenerator = new APIRoutesGenerator($this->commandData); $routesGenerator->generate(); if ($this->commandData->getAddOn('tests')) { $repositoryTestGenerator = new RepositoryTestGenerator($this->commandData); $repositoryTestGenerator->generate(); $testTraitGenerator = new TestTraitGenerator($this->commandData); $testTraitGenerator->generate(); $apiTestGenerator = new ApiTestGenerator($this->commandData); $apiTestGenerator->generate(); } $this->performPostActionsWithMigration(); }