Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Foundation\Console;
4
 
5
use Illuminate\Console\GeneratorCommand;
6
use Symfony\Component\Console\Attribute\AsCommand;
7
use Symfony\Component\Console\Input\InputOption;
8
 
9
#[AsCommand(name: 'make:cast')]
10
class CastMakeCommand extends GeneratorCommand
11
{
12
    /**
13
     * The console command name.
14
     *
15
     * @var string
16
     */
17
    protected $name = 'make:cast';
18
 
19
    /**
20
     * The name of the console command.
21
     *
22
     * This name is used to identify the command during lazy loading.
23
     *
24
     * @var string|null
25
     *
26
     * @deprecated
27
     */
28
    protected static $defaultName = 'make:cast';
29
 
30
    /**
31
     * The console command description.
32
     *
33
     * @var string
34
     */
35
    protected $description = 'Create a new custom Eloquent cast class';
36
 
37
    /**
38
     * The type of class being generated.
39
     *
40
     * @var string
41
     */
42
    protected $type = 'Cast';
43
 
44
    /**
45
     * Get the stub file for the generator.
46
     *
47
     * @return string
48
     */
49
    protected function getStub()
50
    {
51
        return $this->option('inbound')
52
                    ? $this->resolveStubPath('/stubs/cast.inbound.stub')
53
                    : $this->resolveStubPath('/stubs/cast.stub');
54
    }
55
 
56
    /**
57
     * Resolve the fully-qualified path to the stub.
58
     *
59
     * @param  string  $stub
60
     * @return string
61
     */
62
    protected function resolveStubPath($stub)
63
    {
64
        return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
65
            ? $customPath
66
            : __DIR__.$stub;
67
    }
68
 
69
    /**
70
     * Get the default namespace for the class.
71
     *
72
     * @param  string  $rootNamespace
73
     * @return string
74
     */
75
    protected function getDefaultNamespace($rootNamespace)
76
    {
77
        return $rootNamespace.'\Casts';
78
    }
79
 
80
    /**
81
     * Get the console command arguments.
82
     *
83
     * @return array
84
     */
85
    protected function getOptions()
86
    {
87
        return [
88
            ['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the cast already exists'],
89
            ['inbound', null, InputOption::VALUE_NONE, 'Generate an inbound cast class'],
90
        ];
91
    }
92
}