Skip to content

Commit

Permalink
rename commands namespace and added generating livewire table
Browse files Browse the repository at this point in the history
  • Loading branch information
moik.oleksandr committed Nov 16, 2021
1 parent e49b5f9 commit c0be740
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "hexide-digital admin panel",
"license": "MIT",
"type": "library",
"version": "1.0.1",
"version": "1.0.2",
"authors": [
{
"name": "Oleksandr-Moik",
Expand Down
1 change: 1 addition & 0 deletions config/hexide_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
'request' => 'App\\Http\\Requests\\Backend',
'service' => 'App\\Services\\Backend',
'controller' => 'App\\Http\\Controllers\\Backend',
'livewire-table' => 'App\\Http\\Livewire\\Admin\\Tables',
],

// add this line to the file to indicate where to generate the code
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/CreateAdminUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CreateAdminUser extends BaseCommand
*
* @var string
*/
protected $name = 'admin:user';
protected $name = 'hd-admin:user';

/**
* The console command description.
Expand Down
24 changes: 23 additions & 1 deletion src/Console/Commands/HexideAdminCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class HexideAdminCommand extends BaseCommand
*
* @var string
*/
protected $name = 'hexide_admin:module';
protected $name = 'hd-admin:module';

/**
* The console command description.
Expand All @@ -39,6 +39,7 @@ class HexideAdminCommand extends BaseCommand
'request' => 'http/requests',
'service' => 'service',
'controller' => 'http/controllers',
'livewire' => 'http/livewire',

'lang' => 'lang',
'views' => 'views',
Expand Down Expand Up @@ -172,6 +173,7 @@ private function createFiles()
'createRequest' => ['start' => 'Request', 'finish' => 'Request',],
'createController' => ['start' => 'Controller', 'finish' => 'Controller',],
'createViews' => ['start' => 'Views', 'finish' => 'Views',],
'createLivewire' => ['start' => 'Livewire table', 'finish' => 'Livewire table',],
]);

foreach ($methods as $method => $points) {
Expand Down Expand Up @@ -424,6 +426,26 @@ private function createViews()
}
}

private function createLivewire()
{
$path = app_path('Http/Livewire/Admin/Tables/');

$class = $this->getModuleName() . 'Table';

$content = $this->getContent($this->resolveStubPath('livewire', "/table.stub"), [
"{{ namespace }}" => $this->getNamespace('livewire-table', 'App\\Http\\Livewire\\Admin\\Tables'),
"{{ model_namespace }}" => $this->getModelNamespace(),
"{{ model }}" => $this->getSnakeCaseName(),
"{{ ModuleName }}" => $this->getModuleName(),
"{{ module_name }}" => $this->getSnakeCaseName(2),
"{{ class }}" => $class,
]);

$this->makeDir($path);

$this->makeClass($class, $path . $class . '.php', $content, $this->isForced('livewire'));
}

//--------------------------------------------------------

private function prepareResources()
Expand Down
2 changes: 1 addition & 1 deletion src/Console/stubs/menu_item/menu_locale.stub
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
'{{ module_name }}' => trans_choice('models.{{ module_name }}.name', 2),
'{{ ModuleName }}' => trans_choice('models.{{ module_name }}.name', 2),
/*hexide_admin_stub*/

0 comments on commit c0be740

Please sign in to comment.