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:scope')]
10
class ScopeMakeCommand extends GeneratorCommand
11
{
12
    /**
13
     * The console command name.
14
     *
15
     * @var string
16
     */
17
    protected $name = 'make:scope';
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:scope';
29
 
30
    /**
31
     * The console command description.
32
     *
33
     * @var string
34
     */
35
    protected $description = 'Create a new scope class';
36
 
37
    /**
38
     * The type of class being generated.
39
     *
40
     * @var string
41
     */
42
    protected $type = 'Scope';
43
 
44
    /**
45
     * Get the stub file for the generator.
46
     *
47
     * @return string
48
     */
49
    protected function getStub()
50
    {
51
        return $this->resolveStubPath('/stubs/scope.stub');
52
    }
53
 
54
    /**
55
     * Resolve the fully-qualified path to the stub.
56
     *
57
     * @param  string  $stub
58
     * @return string
59
     */
60
    protected function resolveStubPath($stub)
61
    {
62
        return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
63
            ? $customPath
64
            : __DIR__.$stub;
65
    }
66
 
67
    /**
68
     * Get the default namespace for the class.
69
     *
70
     * @param  string  $rootNamespace
71
     * @return string
72
     */
73
    protected function getDefaultNamespace($rootNamespace)
74
    {
75
        return is_dir(app_path('Models')) ? $rootNamespace.'\\Models\\Scopes' : $rootNamespace.'\Scopes';
76
    }
77
 
78
    /**
79
     * Get the console command arguments.
80
     *
81
     * @return array
82
     */
83
    protected function getOptions()
84
    {
85
        return [
86
            ['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the scope already exists'],
87
        ];
88
    }
89
}