Вход Регистрация
Файл: gapps/vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/ValidatorCommand.php
Строк: 87
<?php
namespace PrettusRepositoryGeneratorsCommands;

use 
IlluminateConsoleCommand;
use 
IlluminateSupportCollection;
use 
PrettusRepositoryGeneratorsFileAlreadyExistsException;
use 
PrettusRepositoryGeneratorsValidatorGenerator;
use 
SymfonyComponentConsoleInputInputArgument;
use 
SymfonyComponentConsoleInputInputOption;

class 
ValidatorCommand extends Command
{

    
/**
     * The name of command.
     *
     * @var string
     */
    
protected $name 'make:validator';

    
/**
     * The description of command.
     *
     * @var string
     */
    
protected $description 'Create a new validator.';

    
/**
     * The type of class being generated.
     *
     * @var string
     */
    
protected $type 'Validator';


    
/**
     * Execute the command.
     *
     * @return void
     */
    
public function fire()
    {
        try {
            (new 
ValidatorGenerator([
                
'name' => $this->argument('name'),
                
'rules' => $this->option('rules'),
                
'force' => $this->option('force'),
            ]))->
run();
            
$this->info("Validator created successfully.");
        } catch (
FileAlreadyExistsException $e) {
            
$this->error($this->type ' already exists!');

            return 
false;
        }
    }


    
/**
     * The array of command arguments.
     *
     * @return array
     */
    
public function getArguments()
    {
        return [
            [
                
'name',
                
InputArgument::REQUIRED,
                
'The name of model for which the validator is being generated.',
                
null
            
],
        ];
    }


    
/**
     * The array of command options.
     *
     * @return array
     */
    
public function getOptions()
    {
        return [
            [
                
'rules',
                
null,
                
InputOption::VALUE_OPTIONAL,
                
'The rules of validation attributes.',
                
null
            
],
            [
                
'force',
                
'f',
                
InputOption::VALUE_NONE,
                
'Force the creation if file already exists.',
                
null
            
],
        ];
    }
}
Онлайн: 1
Реклама