add nova
This commit is contained in:
74
nova/src/Console/ActionCommand.php
Normal file
74
nova/src/Console/ActionCommand.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Console;
|
||||
|
||||
use Illuminate\Console\GeneratorCommand;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
#[AsCommand(name: 'nova:action')]
|
||||
class ActionCommand extends GeneratorCommand
|
||||
{
|
||||
use ResolvesStubPath;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'nova:action';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new action class';
|
||||
|
||||
/**
|
||||
* The type of class being generated.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'Action';
|
||||
|
||||
/**
|
||||
* Get the stub file for the generator.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getStub()
|
||||
{
|
||||
$extension = $this->option('queued') ? 'queued.stub' : 'stub';
|
||||
|
||||
if ($this->option('destructive')) {
|
||||
return $this->resolveStubPath("/stubs/nova/destructive-action.{$extension}");
|
||||
}
|
||||
|
||||
return $this->resolveStubPath("/stubs/nova/action.{$extension}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default namespace for the class.
|
||||
*
|
||||
* @param string $rootNamespace
|
||||
* @return string
|
||||
*/
|
||||
protected function getDefaultNamespace($rootNamespace)
|
||||
{
|
||||
return $rootNamespace.'\Nova\Actions';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['destructive', null, InputOption::VALUE_NONE, 'Indicate that the action deletes / destroys resources'],
|
||||
['queued', null, InputOption::VALUE_NONE, 'Indicates the action should be queued'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user