Mercurial > packages > magicforger
view src/Generator/Controller/ControllerGenerator.php @ 40:2cf26b593f4a ls_dev_2025_09 tip
better support for different column types
| author | Luka Sitas <sitas.luka.97@gmail.com> |
|---|---|
| date | Thu, 16 Oct 2025 10:54:04 -0400 |
| parents | 827efbf4d73c |
| children |
line wrap: on
line source
<?php namespace Wizard\MagicForger\Generator\Controller; use Symfony\Component\Console\Attribute\AsCommand; use Wizard\MagicForger\Generator\BaseGenerator; #[AsCommand(name: 'mf:controller')] class ControllerGenerator extends BaseGenerator { /** * The name and signature of the console command. * * @var string */ protected $name = 'mf:controller'; /** * The console command description. * * @var string */ protected $description = 'Generates the Controller File for a table.'; /** * The type of class being generated. * * @var string */ protected $type = 'Controller'; /** * Execute the console command. */ public function handle(): void { parent::handle(); } /** * Get the stub file for the generator. */ protected function getStub(): string { return $this->resolveStubPath('/stubs/controller.stub'); } /** * Resolve the fully-qualified path to the stub. */ protected function resolveStubPath(string $stub): string { $customPath = $this->laravel->basePath(trim($stub, '/')); return is_file($customPath) ? $customPath : __DIR__.$stub; } /** * Get the path for the generated file. */ protected function getPath($name = null) { return str_replace( ['App\\', '\\'], ['app/', '/'], $this->getControllerNamespace().'/'.$this->controller_name($this->getTableInput()).'.php' ); } /** * Get the class name for the controller. */ protected function getClassName(string $name): string { return $this->controller_name($name); } }
