Skip to content

Commit a733cd4

Browse files
Merge pull request #17 from sarahelsagheir/main
Use Str::plural for Dynamic Table Naming in Models and Migrations
2 parents ac3314f + 5fa9e20 commit a733cd4

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/Console/MakeModelCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private function createModuleModel(): void
3939

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

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

src/Console/MakeModuleCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function handle(): int
3434
$this->call('modular:make-model', $params);
3535
$this->call('modular:make-route', $params);
3636

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

4040
$this->call('modular:make-page', $params);

stubs/module-stub/modules/Models/Model.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ class {{ ResourceName }} extends BaseModel
1111
{
1212
use ActivityLog, Searchable, SoftDeletes;
1313

14-
protected $table = '{{ resourceName }}s';
14+
protected $table = '{{ resourceName }}';
1515
}

0 commit comments

Comments
 (0)