comparison src/Generator/Controller/ControllerGenerator.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 ee8ef14e158d
children
comparison
equal deleted inserted replaced
22:ee8ef14e158d 23:827efbf4d73c
29 */ 29 */
30 protected $type = 'Controller'; 30 protected $type = 'Controller';
31 31
32 /** 32 /**
33 * Execute the console command. 33 * Execute the console command.
34 *
35 * @return void
36 */ 34 */
37 public function handle(): void 35 public function handle(): void
38 { 36 {
39 parent::handle(); 37 parent::handle();
40 } 38 }
41 39
42 /** 40 /**
43 * Get the stub file for the generator. 41 * Get the stub file for the generator.
44 *
45 * @return string
46 */ 42 */
47 protected function getStub(): string 43 protected function getStub(): string
48 { 44 {
49 return $this->resolveStubPath('/stubs/controller.stub'); 45 return $this->resolveStubPath('/stubs/controller.stub');
50 } 46 }
51 47
52 /** 48 /**
53 * Resolve the fully-qualified path to the stub. 49 * Resolve the fully-qualified path to the stub.
54 *
55 * @param string $stub
56 * @return string
57 */ 50 */
58 protected function resolveStubPath(string $stub): string 51 protected function resolveStubPath(string $stub): string
59 { 52 {
60 $customPath = $this->laravel->basePath(trim($stub, '/')); 53 $customPath = $this->laravel->basePath(trim($stub, '/'));
61 54
62 return is_file($customPath) ? $customPath : __DIR__ . $stub; 55 return is_file($customPath) ? $customPath : __DIR__.$stub;
63 } 56 }
64 57
65 /** 58 /**
66 * Get the path for the generated file. 59 * Get the path for the generated file.
67 */ 60 */
68 protected function getPath($name = null) 61 protected function getPath($name = null)
69 { 62 {
70 return str_replace( 63 return str_replace(
71 ['App\\', '\\'], 64 ['App\\', '\\'],
72 ['app/', '/'], 65 ['app/', '/'],
73 $this->getControllerNamespace() . '/' . $this->controller_name($this->getTableInput()) . '.php' 66 $this->getControllerNamespace().'/'.$this->controller_name($this->getTableInput()).'.php'
74 ); 67 );
75 } 68 }
76 69
77 /** 70 /**
78 * Get the class name for the controller. 71 * Get the class name for the controller.
79 *
80 * @param string $name
81 * @return string
82 */ 72 */
83 protected function getClassName(string $name): string 73 protected function getClassName(string $name): string
84 { 74 {
85 return $this->controller_name($name); 75 return $this->controller_name($name);
86 } 76 }