Skip to content

Commit

Permalink
feat: private function refactored to protected for extendability
Browse files Browse the repository at this point in the history
  • Loading branch information
mitulgolakiya committed Jul 24, 2022
1 parent c0231fc commit a899872
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 35 deletions.
12 changes: 6 additions & 6 deletions src/Commands/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function performPostActionsWithMigration()
$this->performPostActions(true);
}

private function saveSchemaFile()
protected function saveSchemaFile()
{
$fileFields = [];

Expand Down Expand Up @@ -235,7 +235,7 @@ private function saveSchemaFile()
$this->info($fileName);
}

private function saveLocaleFile()
protected function saveLocaleFile()
{
$locales = [
'singular' => $this->config->modelNames->name,
Expand Down Expand Up @@ -333,7 +333,7 @@ public function getFields()
$this->getFieldsFromConsole();
}

private function getFieldsFromConsole()
protected function getFieldsFromConsole()
{
$this->info('Specify fields for the model (skip id & timestamp fields, we will add it automatically)');
$this->info('Read docs carefully to specify field inputs)');
Expand Down Expand Up @@ -406,7 +406,7 @@ private function addTimestamps()
$this->config->fields[] = $updatedAt;
}

private function parseFieldsFromJsonFile()
protected function parseFieldsFromJsonFile()
{
$fieldsFileValue = $this->option('fieldsFile');
if (file_exists($fieldsFileValue)) {
Expand Down Expand Up @@ -438,7 +438,7 @@ private function parseFieldsFromJsonFile()
}
}

private function parseFieldsFromGUI()
protected function parseFieldsFromGUI()
{
$fileContents = $this->option('jsonFromGUI');
$jsonData = json_decode($fileContents, true);
Expand Down Expand Up @@ -471,7 +471,7 @@ private function parseFieldsFromGUI()
}
}

private function parseFieldsFromTable()
protected function parseFieldsFromTable()
{
$tableName = $this->config->tableName;

Expand Down
2 changes: 1 addition & 1 deletion src/Common/GeneratorField.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function parseOptions(string $options)
}
}

private function prepareMigrationText()
protected function prepareMigrationText()
{
$this->migrationText = '$table->';
$this->migrationText .= $this->dbType."('".$this->name."'";
Expand Down
2 changes: 1 addition & 1 deletion src/Common/GeneratorFieldRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function getRelationFunctionText(string $relationText = null): string
return '';
}

private function generateRelation($functionName, $relation, $relationClass)
protected function generateRelation($functionName, $relation, $relationClass)
{
$inputs = $this->inputs;
$relatedModelName = array_shift($inputs);
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/API/APIControllerGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function generate()
$this->config->commandInfo($this->fileName);
}

private function docsVariables(): array
protected function docsVariables(): array
{
$methods = ['controller', 'index', 'store', 'show', 'update', 'destroy'];

Expand Down
4 changes: 2 additions & 2 deletions src/Generators/API/APIRequestGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function generate()
$this->generateUpdateRequest();
}

private function generateCreateRequest()
protected function generateCreateRequest()
{
$templateData = view('laravel-generator::api.request.create', $this->variables())->render();

Expand All @@ -36,7 +36,7 @@ private function generateCreateRequest()
$this->config->commandInfo($this->createFileName);
}

private function generateUpdateRequest()
protected function generateUpdateRequest()
{
$modelGenerator = app(ModelGenerator::class);
$rules = $modelGenerator->generateUniqueRules();
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/API/APIResourceGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function generate()
$this->config->commandInfo($this->fileName);
}

private function generateResourceFields(): array
protected function generateResourceFields(): array
{
$resourceFields = [];
foreach ($this->config->fields as $field) {
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/FactoryGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function generate()
$this->config->commandInfo($this->fileName);
}

private function generateFields(): string
protected function generateFields(): string
{
$fields = [];

Expand Down
2 changes: 1 addition & 1 deletion src/Generators/MigrationGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function variables(): array
];
}

private function generateFields(): string
protected function generateFields(): string
{
$fields = [];
$foreignKeys = [];
Expand Down
8 changes: 4 additions & 4 deletions src/Generators/ModelGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected function generateFillables(): array
return $fillables;
}

private function fillDocs(): string
protected function fillDocs(): string
{
if (!$this->config->options->swagger) {
return '';
Expand Down Expand Up @@ -145,7 +145,7 @@ public function generateSwagger(): string
]);
}

private function generateRequiredFields(): array
protected function generateRequiredFields(): array
{
$requiredFields = [];

Expand All @@ -162,7 +162,7 @@ private function generateRequiredFields(): array
return $requiredFields;
}

private function generateRules(): array
protected function generateRules(): array
{
$dont_require_fields = config('laravel_generator.options.hidden_fields', [])
+ config('laravel_generator.options.excluded_fields', $this->excluded_fields);
Expand Down Expand Up @@ -309,7 +309,7 @@ public function generateCasts(): array
return $casts;
}

private function generateRelations(): string
protected function generateRelations(): string
{
$relations = [];

Expand Down
8 changes: 4 additions & 4 deletions src/Generators/Scaffold/ControllerGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function generate()
$this->config->commandInfo($this->fileName);
}

private function generateDataTable()
protected function generateDataTable()
{
$templateData = view('laravel-generator::scaffold.table.datatable', [
'columns' => implode(','.infy_nl_tab(1, 3), $this->generateDataTableColumns()),
Expand All @@ -81,7 +81,7 @@ private function generateDataTable()
$this->config->commandInfo($fileName);
}

private function generateLivewireTable()
protected function generateLivewireTable()
{
$templateData = view('laravel-generator::scaffold.table.livewire', [
'columns' => implode(','.infy_nl_tab(1, 3), $this->generateLivewireTableColumns()),
Expand All @@ -97,7 +97,7 @@ private function generateLivewireTable()
$this->config->commandInfo($fileName);
}

private function generateDataTableColumns(): array
protected function generateDataTableColumns(): array
{
$dataTableColumns = [];
foreach ($this->config->fields as $field) {
Expand All @@ -114,7 +114,7 @@ private function generateDataTableColumns(): array
return $dataTableColumns;
}

private function generateLivewireTableColumns(): array
protected function generateLivewireTableColumns(): array
{
$livewireTableColumns = [];

Expand Down
4 changes: 2 additions & 2 deletions src/Generators/Scaffold/RequestGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function generate()
$this->generateUpdateRequest();
}

private function generateCreateRequest()
protected function generateCreateRequest()
{
$templateData = view('laravel-generator::scaffold.request.create', $this->variables())->render();

Expand All @@ -36,7 +36,7 @@ private function generateCreateRequest()
$this->config->commandInfo($this->createFileName);
}

private function generateUpdateRequest()
protected function generateUpdateRequest()
{
$modelGenerator = new ModelGenerator();
$rules = $modelGenerator->generateUniqueRules();
Expand Down
22 changes: 11 additions & 11 deletions src/Generators/Scaffold/ViewGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function generate()
$this->config->commandComment('Views created: ');
}

private function generateTable()
protected function generateTable()
{
if ($this->config->tableType === 'livewire') {
return;
Expand All @@ -99,12 +99,12 @@ private function generateTable()
$this->config->commandInfo('table.blade.php created');
}

private function generateDataTableBody(): string
protected function generateDataTableBody(): string
{
return view($this->templateViewPath.'.scaffold.table.datatable.body')->render();
}

private function generateDataTableActions()
protected function generateDataTableActions()
{
$templateData = view($this->templateViewPath.'.scaffold.table.datatable.actions')->render();

Expand All @@ -113,7 +113,7 @@ private function generateDataTableActions()
$this->config->commandInfo('datatables_actions.blade.php created');
}

private function generateBladeTableBody(): string
protected function generateBladeTableBody(): string
{
$tableBodyFields = [];

Expand All @@ -139,7 +139,7 @@ private function generateBladeTableBody(): string
])->render();
}

private function generateTableHeaderFields(): string
protected function generateTableHeaderFields(): string
{
$headerFields = [];

Expand All @@ -157,7 +157,7 @@ private function generateTableHeaderFields(): string
return implode(infy_nl_tab(1, 4), $headerFields);
}

private function generateIndex()
protected function generateIndex()
{
switch ($this->config->tableType) {
case 'datatables':
Expand All @@ -181,7 +181,7 @@ private function generateIndex()
$this->config->commandInfo('index.blade.php created');
}

private function generateFields()
protected function generateFields()
{
$htmlFields = [];

Expand Down Expand Up @@ -246,23 +246,23 @@ private function generateViewComposer($tableName, $variableName, $columns, $sele
);
}

private function generateCreate()
protected function generateCreate()
{
$templateData = view($this->templateViewPath.'.scaffold.create')->render();

g_filesystem()->createFile($this->path.'create.blade.php', $templateData);
$this->config->commandInfo('create.blade.php created');
}

private function generateUpdate()
protected function generateUpdate()
{
$templateData = view($this->templateViewPath.'.scaffold.edit')->render();

g_filesystem()->createFile($this->path.'edit.blade.php', $templateData);
$this->config->commandInfo('edit.blade.php created');
}

private function generateShowFields()
protected function generateShowFields()
{
$fieldsStr = '';

Expand All @@ -279,7 +279,7 @@ private function generateShowFields()
$this->config->commandInfo('show_fields.blade.php created');
}

private function generateShow()
protected function generateShow()
{
$templateData = view($this->templateViewPath.'.scaffold.show')->render();

Expand Down

0 comments on commit a899872

Please sign in to comment.