Mercurial > packages > magicforger
view src/Generator/Controller/ControllerGenerator.php @ 4:a20439b1c9d3
Added Model generator and other updates.
| author | luka |
|---|---|
| date | Tue, 27 Jun 2023 20:16:55 -0400 |
| parents | 6468684362c2 |
| children | b0b2e79ad8e6 |
line wrap: on
line source
<?php namespace Wizzard\MagicForger\Generator\Controller; use Symfony\Component\Console\Attribute\AsCommand; use Wizzard\MagicForger\Generator\BaseGenerator; use Wizzard\MagicForger\Replacer; use Illuminate\Support\Str; #[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() { parent::handle(); } /** * Get the stub file for the generator. * * @return string */ protected function getStub() { return $this->resolveStubPath('/stubs/controller.stub'); } /** * Resolve the fully-qualified path to the stub. * * @param string $stub * @return string */ protected function resolveStubPath($stub) { return is_file($customPath = $this->laravel->basePath(trim($stub, '/'))) ? $customPath : __DIR__.$stub; } protected function getClassName($name) { return $this->controller_name($name); } /** * Get the stub file for the generator. * * @return string */ protected function getPath($name = null) { return str_replace(['App\\', '\\'], ['app/', '/'], $this->getControllerNamespace() . '/' . $this->controller_name($this->getTableInput()) . '.php'); } }
