Skip to content

Commit

Permalink
- Generate stubs and 100% customize
Browse files Browse the repository at this point in the history
- Added config option for more namespaces
  • Loading branch information
awais-vteams committed Jun 11, 2024
1 parent 1656376 commit 0622abe
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/Commands/GeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ public function __construct(Filesystem $files)
$this->unwantedColumns = config('crud.model.unwantedColumns', $this->unwantedColumns);
$this->modelNamespace = config('crud.model.namespace', $this->modelNamespace);
$this->controllerNamespace = config('crud.controller.namespace', $this->controllerNamespace);
$this->apiControllerNamespace = config('crud.controller.apiNamespace', $this->apiControllerNamespace);
$this->resourceNamespace = config('crud.resources.namespace', $this->resourceNamespace);
$this->livewireNamespace = config('crud.livewire.namespace', $this->livewireNamespace);
$this->requestNamespace = config('crud.request.namespace', $this->requestNamespace);
$this->layout = config('crud.layout', $this->layout);
}

Expand Down Expand Up @@ -147,7 +151,7 @@ protected function getStub(string $type, bool $content = true): string
{
$stub_path = config('crud.stub_path', 'default');

if ($stub_path == 'default') {
if (blank($stub_path) || $stub_path == 'default') {
$stub_path = __DIR__.'/../stubs/';
}

Expand Down
4 changes: 4 additions & 0 deletions src/CrudServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public function boot()
$this->publishes([
__DIR__.'/config/crud.php' => config_path('crud.php'),
], 'crud');

$this->publishes([
__DIR__.'/../src/stubs' => resource_path('stubs/crud/'),
], 'stubs-crud');
}

/**
Expand Down
32 changes: 24 additions & 8 deletions src/config/crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@
| stubs paths here, allowing you to customize the own stubs of the
| model,controller or view. Or, you may simply stick with the CrudGenerator defaults!
|
| Example: 'stub_path' => resource_path('path/to/views/stubs/')
| Example: 'stub_path' => resource_path('stubs/')
| Default: "default"
| Files:
| Controller.stub
| Model.stub
| Request.stub
| views/
| create.stub
| edit.stub
| form.stub
| form-field.stub
| index.stub
| show.stub
| view-field.stub
| bootstrap/
| create.stub
| edit.stub
| form.stub
| form-field.stub
| index.stub
| show.stub
| view-field.stub
*/

'stub_path' => 'default',
Expand All @@ -48,6 +50,8 @@
*/
'unwantedColumns' => [
'id',
'uuid',
'ulid',
'password',
'email_verified_at',
'remember_token',
Expand All @@ -59,6 +63,18 @@

'controller' => [
'namespace' => 'App\Http\Controllers',
'apiNamespace' => 'App\Http\Controllers\Api',
],

'resources' => [
'namespace' => 'App\Http\Resources',
],

'livewire' => [
'namespace' => 'App\Livewire',
],

'request' => [
'namespace' => 'App\Http\Requests',
],
];

0 comments on commit 0622abe

Please sign in to comment.