Skip to content
This repository was archived by the owner on Feb 18, 2024. It is now read-only.

Commit 46bd3a9

Browse files
author
atehnix
committed
Update make:controller command
1 parent 5fd3017 commit 46bd3a9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Console/ControllerMakeCommand.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,24 @@ class ControllerMakeCommand extends BaseControllerMakeCommand
3030
*/
3131
protected function getStub()
3232
{
33+
$stub = null;
34+
3335
if ($this->option('parent')) {
3436
$stub = config('stubs.path') . '/controller.nested.stub';
3537
} elseif ($this->option('model')) {
3638
$stub = config('stubs.path') . '/controller.model.stub';
3739
} elseif ($this->option('resource')) {
3840
$stub = config('stubs.path') . '/controller.stub';
39-
} else {
40-
$stub = config('stubs.path') . '/controller.plain.stub';
4141
}
4242

43+
if ($this->option('api') && is_null($stub)) {
44+
$stub = config('stubs.path') . '/controller.api.stub';
45+
} elseif ($this->option('api') && !is_null($stub)) {
46+
$stub = config('stubs.path') . str_replace('.stub', '.api.stub', $stub);
47+
}
48+
49+
$stub = $stub ?? config('stubs.path') . '/controller.plain.stub';
50+
4351
return file_exists($stub) ? $stub : parent::getStub();
4452
}
4553

0 commit comments

Comments
 (0)