Skip to content

Commit

Permalink
[11.x] Add namespace for make:trait and make:interface command (#…
Browse files Browse the repository at this point in the history
…51083)

* Update InterfaceMakeCommand.php

* Update TraitMakeCommand.php

* Update TraitMakeCommand.php

---------

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
milwad-dev and taylorotwell authored Apr 16, 2024
1 parent a0ffb2b commit 248e117
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Illuminate/Foundation/Console/InterfaceMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ protected function getStub()
return __DIR__.'/stubs/interface.stub';
}

/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
* @return string
*/
protected function getDefaultNamespace($rootNamespace)
{
return match (true) {
is_dir(app_path('Contracts')) => $rootNamespace.'\\Contracts',
is_dir(app_path('Interfaces')) => $rootNamespace.'\\Interfaces',
default => $rootNamespace,
};
}

/**
* Get the console command arguments.
*
Expand Down
15 changes: 15 additions & 0 deletions src/Illuminate/Foundation/Console/TraitMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ protected function resolveStubPath($stub)
: __DIR__.$stub;
}

/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
* @return string
*/
protected function getDefaultNamespace($rootNamespace)
{
return match (true) {
is_dir(app_path('Concerns')) => $rootNamespace.'\\Concerns',
is_dir(app_path('Traits')) => $rootNamespace.'\\Traits',
default => $rootNamespace,
};
}

/**
* Get the console command arguments.
*
Expand Down

0 comments on commit 248e117

Please sign in to comment.