75 lines
1.7 KiB
PHP
75 lines
1.7 KiB
PHP
<?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'],
|
|
];
|
|
}
|
|
}
|