@@ -48,6 +48,8 @@ final class PowerGridComponentMaker
4848
4949 private string $ modelFqn = '' ;
5050
51+ private string $ tableName = '' ;
52+
5153 private bool $ autoCreateColumns = false ;
5254
5355 private bool $ usesCustomStub = false ;
@@ -59,7 +61,8 @@ public function __construct(string $name)
5961 $ this ->resolveNameFolderFilename (SanitizeComponentName::handle ($ name ))
6062 ->resolveNamespace ()
6163 ->resolveFqn ()
62- ->resolveHtmlTag ();
64+ ->resolveHtmlTag ()
65+ ->resolveTableName ();
6366 }
6467
6568 public static function make (string $ name ): self
@@ -177,6 +180,7 @@ private function process(): self
177180 {
178181 $ this ->stub ->setVar ('namespace ' , $ this ->namespace );
179182 $ this ->stub ->setVar ('componentName ' , $ this ->name );
183+ $ this ->stub ->setVar ('tableName ' , $ this ->tableName );
180184
181185 $ this ->stub ->setVar ('model ' , $ this ->model );
182186 $ this ->stub ->setVar ('modelFqn ' , $ this ->modelFqn );
@@ -242,9 +246,9 @@ private function resolveFqn(): self
242246 public function createdPath (): string
243247 {
244248 return str ($ this ->namespace )
245- ->replace ('App ' , 'app ' )
246- ->append ('\\' . $ this ->filename )
247- ->replace ('\\' , '/ ' );
249+ ->replace ('App ' , 'app ' )
250+ ->append ('\\' . $ this ->filename )
251+ ->replace ('\\' , '/ ' );
248252 }
249253
250254 private function resolveHtmlTag (): self
@@ -261,6 +265,17 @@ private function resolveHtmlTag(): self
261265 return $ this ;
262266 }
263267
268+ private function resolveTableName (): self
269+ {
270+ $ this ->tableName = str ($ this ->name )
271+ ->kebab ()
272+ ->append ('- ' . Str::random (6 ))
273+ ->append ('-table ' )
274+ ->lower ();
275+
276+ return $ this ;
277+ }
278+
264279 private function livewireNamespace (): string
265280 {
266281 return strval (config ('livewire.class_namespace ' ));
0 commit comments