/** * The console command description. * * @var string */ protected$description = 'Create a new queryController class';
/** * The type of class being generated. * * @var string */ protected$type = 'QueryController';
/** * Get the stub file for the generator. * * @return string */ protectedfunctiongetStub() { returnresource_path('stubs/queryController.stub'); }
/** * Get the default namespace for the class. * * @param string $rootNamespace * @return string */ protectedfunctiongetDefaultNamespace($rootNamespace) { return$rootNamespace.'\Http\Controllers'; }
/** * Build the class with the given name. * * Remove the base controller import if we are already in base namespace. * * @param string $name * @return string */ protectedfunctionbuildClass($name) { $controllerNamespace = $this->getNamespace($name);
$replace = [];
if ($this->option('model')) { $replace = $this->buildModelReplacements($replace); }
if (! class_exists($modelClass)) { if ($this->confirm("A {$modelClass} model does not exist. Do you want to generate it?", true)) { $this->call('make:model', ['name' => $modelClass]); } }
/** * Get the fully-qualified model class name. * * @param string $model * @return string */ protectedfunctionparseModel($model) { // if (preg_match('([^A-Za-z0-9_/\\\\])', $model)) { // throw new InvalidArgumentException('Model name contains invalid characters.'); // }
/** * Get the console command options. * * @return array */ protectedfunctiongetOptions() { return [ ['model', 'm', InputOption::VALUE_OPTIONAL, 'Generate a query controller for the given model.'], ]; } }