comparison src/Generator/View/ShowViewGenerator.php @ 34:f65ab84ee47f default

merge with codex
author luka
date Wed, 10 Sep 2025 21:00:47 -0400
parents 1a717c7b211f
children
comparison
equal deleted inserted replaced
10:a9ff874afdbd 34:f65ab84ee47f
1 <?php
2
3 namespace Wizard\MagicForger\Generator\View;
4
5 use Symfony\Component\Console\Attribute\AsCommand;
6 use Wizard\MagicForger\Generator\BaseGenerator;
7
8 #[AsCommand(name: 'mf:show_view')]
9 class ShowViewGenerator extends BaseGenerator
10 {
11 /**
12 * The name and signature of the console command.
13 *
14 * @var string
15 */
16 protected $name = 'mf:show_view';
17
18 /**
19 * The console command description.
20 *
21 * @var string
22 */
23 protected $description = 'Generates the ShowView File for a table.';
24
25 /**
26 * The type of class being generated.
27 *
28 * @var string
29 */
30 protected $type = 'ShowView';
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/show.stub');
48 }
49
50 /**
51 * Resolve the fully-qualified path to the stub.
52 *
53 * @param string $stub
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->show_view_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 {
75 return str_replace(['Resources\\', '\\'], ['resources/', '/'], $this->getViewNamespace($this->getTableInput()).'show.blade.php');
76 }
77 }