Mercurial > packages > magicforger
annotate src/Generator/Requests/StoreRequestGenerator.php @ 23:827efbf4d73c main-dev
Huge changes to the relationships for models and more complex
| author | Luka Sitas <sitas.luka.97@gmail.com> |
|---|---|
| date | Fri, 11 Apr 2025 20:50:20 -0400 |
| parents | 81a76472ba21 |
| children |
| rev | line source |
|---|---|
| 5 | 1 <?php |
| 2 | |
| 20 | 3 namespace Wizard\MagicForger\Generator\Requests; |
| 5 | 4 |
| 5 use Symfony\Component\Console\Attribute\AsCommand; | |
| 20 | 6 use Wizard\MagicForger\Generator\BaseGenerator; |
| 5 | 7 |
| 8 #[AsCommand(name: 'mf:store_request')] | |
| 9 class StoreRequestGenerator extends BaseGenerator | |
| 10 { | |
| 11 /** | |
| 12 * The name and signature of the console command. | |
| 13 * | |
| 14 * @var string | |
| 15 */ | |
| 16 protected $name = 'mf:store_request'; | |
| 17 | |
| 18 /** | |
| 19 * The console command description. | |
| 20 * | |
| 21 * @var string | |
| 22 */ | |
| 23 protected $description = 'Generates the StoreRequest File for a table.'; | |
| 24 | |
| 25 /** | |
| 26 * The type of class being generated. | |
| 27 * | |
| 28 * @var string | |
| 29 */ | |
| 30 protected $type = 'StoreRequest'; | |
| 31 | |
| 32 /** | |
| 33 * Execute the console command. | |
| 34 */ | |
| 35 public function handle() | |
| 36 { | |
| 37 parent::handle(); | |
| 38 } | |
| 39 | |
| 40 /** | |
| 41 * Get the stub file for the generator. | |
| 42 * | |
| 43 * @return string | |
| 44 */ | |
| 45 protected function getStub() | |
| 46 { | |
| 47 return $this->resolveStubPath('/stubs/request.stub'); | |
| 48 } | |
| 49 | |
| 50 /** | |
| 51 * Resolve the fully-qualified path to the stub. | |
| 52 * | |
|
23
827efbf4d73c
Huge changes to the relationships for models and more complex
Luka Sitas <sitas.luka.97@gmail.com>
parents:
20
diff
changeset
|
53 * @param string $stub |
| 5 | 54 * @return string |
| 55 */ | |
| 56 protected function resolveStubPath($stub) | |
| 57 { | |
| 58 return is_file($customPath = $this->laravel->basePath(trim($stub, '/'))) | |
| 59 ? $customPath | |
| 60 : __DIR__.$stub; | |
| 61 } | |
| 62 | |
| 63 protected function getClassName($name) | |
| 64 { | |
| 65 return $this->store_request_name($name); | |
| 66 } | |
| 67 | |
| 68 /** | |
| 69 * Get the stub file for the generator. | |
| 70 * | |
| 71 * @return string | |
| 72 */ | |
| 73 protected function getPath($name = null) | |
| 74 { | |
|
7
769a17898cc0
Various changes to the generators and replacers - probably mostly just formatting
luka
parents:
5
diff
changeset
|
75 return str_replace(['App\\', '\\'], ['app/', '/'], $this->getRequestNamespace($this->getTableInput()).'/'.$this->store_request_name($this->getTableInput()).'.php'); |
| 5 | 76 } |
| 77 } |
