comparison src/Generator/Requests/UpdateRequestGenerator.php @ 5:b0b2e79ad8e6

Not exatly sure what was changed but commiting to it :)
author luka
date Thu, 12 Oct 2023 19:41:04 -0400
parents
children 769a17898cc0
comparison
equal deleted inserted replaced
4:a20439b1c9d3 5:b0b2e79ad8e6
1 <?php
2
3 namespace Wizzard\MagicForger\Generator\Requests;
4
5 use Symfony\Component\Console\Attribute\AsCommand;
6 use Wizzard\MagicForger\Generator\BaseGenerator;
7 use Wizzard\MagicForger\Replacer;
8 use Illuminate\Support\Str;
9
10 #[AsCommand(name: 'mf:update_request')]
11 class UpdateRequestGenerator extends BaseGenerator
12 {
13 /**
14 * The name and signature of the console command.
15 *
16 * @var string
17 */
18 protected $name = 'mf:update_request';
19
20 /**
21 * The console command description.
22 *
23 * @var string
24 */
25 protected $description = 'Generates the UpdateRequest File for a table.';
26
27 /**
28 * The type of class being generated.
29 *
30 * @var string
31 */
32 protected $type = 'UpdateRequest';
33
34 /**
35 * Execute the console command.
36 */
37 public function handle()
38 {
39 parent::handle();
40 }
41
42 /**
43 * Get the stub file for the generator.
44 *
45 * @return string
46 */
47 protected function getStub()
48 {
49 return $this->resolveStubPath('/stubs/request.stub');
50 }
51
52 /**
53 * Resolve the fully-qualified path to the stub.
54 *
55 * @param string $stub
56 * @return string
57 */
58 protected function resolveStubPath($stub)
59 {
60 return is_file($customPath = $this->laravel->basePath(trim($stub, '/')))
61 ? $customPath
62 : __DIR__.$stub;
63 }
64
65 protected function getClassName($name)
66 {
67 return $this->update_request_name($name);
68 }
69
70 /**
71 * Get the stub file for the generator.
72 *
73 * @return string
74 */
75 protected function getPath($name = null)
76 {
77 return str_replace(['App\\', '\\'], ['app/', '/'], $this->getRequestNamespace($this->getTableInput()) . '/' . $this->update_request_name($this->getTableInput()) . '.php');
78 }
79 }