Skip to content

Commit e448368

Browse files
use camelCame with generated table (#2032)
* use camelCame with generated table * fix: update tableName generation to use str_ends_with and ensure camelCase format --------- Co-authored-by: luanfreitasdev <[email protected]>
1 parent cdccf65 commit e448368

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/Commands/Support/PowerGridComponentMaker.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,11 @@ private function resolveHtmlTag(): self
269269
private function resolveTableName(): self
270270
{
271271
$this->tableName = str($this->name)
272-
->kebab()
273-
->append('-'.Str::random(6))
274-
->append('-table')
275-
->lower();
272+
->camel();
273+
274+
if (! str_ends_with($this->name, 'Table')) {
275+
$this->tableName = str($this->tableName)->append('Table');
276+
}
276277

277278
return $this;
278279
}

tests/Feature/Support/PowerGridMakerTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,15 @@
162162

163163
expect($component->savePath($component->filename))->toEndWith(str_replace('/', DIRECTORY_SEPARATOR, 'Domains/System/Office/Users/Admin/Active/ListTable.php'));
164164
});
165+
166+
it('tableName is converted to camelCase', function () {
167+
$component = PowerGridComponentMaker::make('System/Office/Users/Admin/Active/ListTable');
168+
169+
expect($component->tableName)->toBe('listTable');
170+
});
171+
172+
it('tableName appends Table to the end of the name', function () {
173+
$component = PowerGridComponentMaker::make('System/Office/Users/Admin/Active/List');
174+
175+
expect($component->tableName)->toBe('listTable');
176+
});

0 commit comments

Comments
 (0)