Skip to content

Commit 0622abe

Browse files
committed
- Generate stubs and 100% customize
- Added config option for more namespaces
1 parent 1656376 commit 0622abe

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

src/Commands/GeneratorCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ public function __construct(Filesystem $files)
8181
$this->unwantedColumns = config('crud.model.unwantedColumns', $this->unwantedColumns);
8282
$this->modelNamespace = config('crud.model.namespace', $this->modelNamespace);
8383
$this->controllerNamespace = config('crud.controller.namespace', $this->controllerNamespace);
84+
$this->apiControllerNamespace = config('crud.controller.apiNamespace', $this->apiControllerNamespace);
85+
$this->resourceNamespace = config('crud.resources.namespace', $this->resourceNamespace);
86+
$this->livewireNamespace = config('crud.livewire.namespace', $this->livewireNamespace);
87+
$this->requestNamespace = config('crud.request.namespace', $this->requestNamespace);
8488
$this->layout = config('crud.layout', $this->layout);
8589
}
8690

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

150-
if ($stub_path == 'default') {
154+
if (blank($stub_path) || $stub_path == 'default') {
151155
$stub_path = __DIR__.'/../stubs/';
152156
}
153157

src/CrudServiceProvider.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public function boot()
2626
$this->publishes([
2727
__DIR__.'/config/crud.php' => config_path('crud.php'),
2828
], 'crud');
29+
30+
$this->publishes([
31+
__DIR__.'/../src/stubs' => resource_path('stubs/crud/'),
32+
], 'stubs-crud');
2933
}
3034

3135
/**

src/config/crud.php

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@
1111
| stubs paths here, allowing you to customize the own stubs of the
1212
| model,controller or view. Or, you may simply stick with the CrudGenerator defaults!
1313
|
14-
| Example: 'stub_path' => resource_path('path/to/views/stubs/')
14+
| Example: 'stub_path' => resource_path('stubs/')
1515
| Default: "default"
1616
| Files:
1717
| Controller.stub
1818
| Model.stub
19+
| Request.stub
1920
| views/
20-
| create.stub
21-
| edit.stub
22-
| form.stub
23-
| form-field.stub
24-
| index.stub
25-
| show.stub
26-
| view-field.stub
21+
| bootstrap/
22+
| create.stub
23+
| edit.stub
24+
| form.stub
25+
| form-field.stub
26+
| index.stub
27+
| show.stub
28+
| view-field.stub
2729
*/
2830

2931
'stub_path' => 'default',
@@ -48,6 +50,8 @@
4850
*/
4951
'unwantedColumns' => [
5052
'id',
53+
'uuid',
54+
'ulid',
5155
'password',
5256
'email_verified_at',
5357
'remember_token',
@@ -59,6 +63,18 @@
5963

6064
'controller' => [
6165
'namespace' => 'App\Http\Controllers',
66+
'apiNamespace' => 'App\Http\Controllers\Api',
6267
],
6368

69+
'resources' => [
70+
'namespace' => 'App\Http\Resources',
71+
],
72+
73+
'livewire' => [
74+
'namespace' => 'App\Livewire',
75+
],
76+
77+
'request' => [
78+
'namespace' => 'App\Http\Requests',
79+
],
6480
];

0 commit comments

Comments
 (0)