Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Hesammousavi committed May 24, 2024
1 parent b3d70c6 commit cadedda
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions src/Commands/Laravel/MakeModulePolicy.php
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'],
];
}
}

0 comments on commit cadedda

Please sign in to comment.