I am developing a Laravel package that will use a custom artisan command i.e php artisan make:baserepository User -c. -c means I will create a controller as well.
I want when I run this artisan command, I am able to create a controller. Here is my code that creates the controller.
protected function createController() {
$modelsingular = Str::singular(Str::ucfirst($this->getNameInput()));
$modelplural = Str::plural($modelsingular);
$controller = Str::studly(class_basename($this->argument('name')));
$modelName = $this->qualifyClass($modelplural . '/' . $modelsingular);
$this->call('make:controller', [
'name' => "{$modelplural}\{$controller}Controller",
'--model' => $this->option('resource') ? $modelName : null,
]);
}
Take a look at this line 'name' => "{$modelplural}\{$controller}Controller". I want the controller to be like this Admin\Admin.php in Http\Controllers, instead I am getting Admin\{Admin}Controller.php. Where am I getting it wrong?
I hope my question is clear.
'name' => $modelplural.'\'.$controller.'Controller'.