-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3d70c6
commit cadedda
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace Hesammousavi\LaravelModuleCreator\Commands\Laravel; | ||
|
||
use Hesammousavi\LaravelModuleCreator\Traits\RequireModule; | ||
use Illuminate\Foundation\Console\PolicyMakeCommand; | ||
use Illuminate\Support\Str; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
|
||
class MakeModulePolicy extends PolicyMakeCommand | ||
{ | ||
use RequireModule; | ||
/** | ||
* The console command name. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'm:make:policy'; | ||
|
||
/** | ||
* The name of the console command. | ||
* | ||
* This name is used to identify the command during lazy loading. | ||
* | ||
* @var string|null | ||
* | ||
* @deprecated | ||
*/ | ||
protected static $defaultName = 'm:make:policy'; | ||
|
||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Create a new policy class for module'; | ||
|
||
/** | ||
* Get the destination class path. | ||
* | ||
* @param string $name | ||
* @return string | ||
*/ | ||
protected function getPath($name) | ||
{ | ||
$name = Str::replaceFirst($this->rootNamespace(), '', $name); | ||
|
||
return base_path("modules/{$this->argument('module')}/src") . '/' . str_replace('\\', '/', $name) . '.php'; | ||
} | ||
|
||
|
||
protected function rootNamespace() | ||
{ | ||
return str_replace('/', '\\', $this->argument('module')); | ||
} | ||
|
||
/** | ||
* Get the console command arguments. | ||
* | ||
* @return array | ||
*/ | ||
protected function getArguments() | ||
{ | ||
return [ | ||
['module', InputArgument::REQUIRED, 'the name of the module'], | ||
['name', InputArgument::REQUIRED, 'The name of the class'], | ||
]; | ||
} | ||
} |