Mercurial > packages > magicforger
view examples/ExampleGenerator.php.stub @ 29:010ace248d14 codex
Added support for filters, not fully there with relations or anything like that but it's a start
| author | Luka Sitas <sitas.luka.97@gmail.com> |
|---|---|
| date | Mon, 09 Jun 2025 20:51:04 -0400 |
| parents | b0b2e79ad8e6 |
| children |
line wrap: on
line source
<?php namespace Wizzard\MagicForger\Generator\{{ Class Name }}; use Symfony\Component\Console\Attribute\AsCommand; use Wizzard\MagicForger\Generator\BaseGenerator; use Wizzard\MagicForger\Replacer; use Illuminate\Support\Str; #[AsCommand(name: 'mf:{{ Command Name }}')] class {{ Class Name }}Generator extends BaseGenerator { /** * The name and signature of the console command. * * @var string */ protected $name = 'mf:{{ Command Name }}'; /** * The console command description. * * @var string */ protected $description = 'Generates the {{ Class Name }} File for a table.'; /** * The type of class being generated. * * @var string */ protected $type = '{{ Class Name }}'; /** * 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/{{ Command Name }}.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->{{ Command Name }}_name($name); } /** * Get the stub file for the generator. * * @return string */ protected function getPath($name = null) { return str_replace(['App\\', '\\'], ['app/', '/'], $this->get{{ Class Name }}Namespace() . '/' . $this->{{ Command Name }}_name($this->getTableInput()) . '.php'); } }
