diff --git a/src/Generators/DataTablesHtmlCommand.php b/src/Generators/DataTablesHtmlCommand.php index 983cf57..5406ca0 100644 --- a/src/Generators/DataTablesHtmlCommand.php +++ b/src/Generators/DataTablesHtmlCommand.php @@ -41,7 +41,7 @@ class DataTablesHtmlCommand extends DataTablesMakeCommand * * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ - protected function buildClass($name) + protected function buildClass($name): string { $stub = $this->files->get($this->getStub()); diff --git a/src/Generators/DataTablesMakeCommand.php b/src/Generators/DataTablesMakeCommand.php index a0ae5bb..2a4c2d8 100644 --- a/src/Generators/DataTablesMakeCommand.php +++ b/src/Generators/DataTablesMakeCommand.php @@ -48,7 +48,7 @@ public function handle() $dom = config('datatables-buttons.generator.dom', 'Bfrtip'); $this->call('datatables:html', [ - 'name' => $this->prepareHtmlBuilderName($this->getNameInput()), + 'name' => $this->getDataTableBaseName(), '--columns' => $this->option('columns') ?: $columns, '--buttons' => $this->option('buttons') ?: $buttons, '--dom' => $this->option('dom') ?: $dom, @@ -65,7 +65,7 @@ public function handle() * * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ - protected function buildClass($name) + protected function buildClass($name): string { $stub = parent::buildClass($name); @@ -83,13 +83,13 @@ protected function buildClass($name) } /** - * Prepare html builder name from input. + * Get DataTable class base name without the suffix. * * @return string */ - protected function prepareHtmlBuilderName(): string + protected function getDataTableBaseName(): string { - return preg_replace('#datatable$#i', '', $this->getNameInput()); + return (string) preg_replace('#datatable$#i', '', $this->getNameInput()); } /** @@ -99,7 +99,7 @@ protected function prepareHtmlBuilderName(): string */ protected function prepareModelName(): string { - return basename(preg_replace('#datatable$#i', '', $this->getNameInput())); + return basename($this->getDataTableBaseName()); } /**