Skip to content

Commit

Permalink
Merge pull request #17 from sarahelsagheir/main
Browse files Browse the repository at this point in the history
Use Str::plural for Dynamic Table Naming in Models and Migrations
  • Loading branch information
daniel-cintra authored Dec 14, 2024
2 parents ac3314f + 5fa9e20 commit a733cd4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Console/MakeModelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private function createModuleModel(): void

$stub = str_replace('{{ ModuleName }}', $this->moduleName, $stub);
$stub = str_replace('{{ ResourceName }}', $this->resourceName, $stub);
$stub = str_replace('{{ resourceName }}', Str::camel($this->resourceName), $stub);
$stub = str_replace('{{ resourceName }}', Str::camel(Str::plural($this->resourceName)), $stub);

$path = base_path("modules/{$this->moduleName}/Models/{$this->resourceName}.php");

Expand Down
2 changes: 1 addition & 1 deletion src/Console/MakeModuleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function handle(): int
$this->call('modular:make-model', $params);
$this->call('modular:make-route', $params);

$this->call('modular:make-migration', ['moduleName' => $this->moduleName, 'migrationName' => "create{$this->moduleName}s_table"]);
$this->call('modular:make-migration', ['moduleName' => $this->moduleName, 'migrationName' => 'create'.Str::plural($this->moduleName).'_table']);
$this->call('modular:make-factory', $params);

$this->call('modular:make-page', $params);
Expand Down
2 changes: 1 addition & 1 deletion stubs/module-stub/modules/Models/Model.stub
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ class {{ ResourceName }} extends BaseModel
{
use ActivityLog, Searchable, SoftDeletes;

protected $table = '{{ resourceName }}s';
protected $table = '{{ resourceName }}';
}

0 comments on commit a733cd4

Please sign in to comment.