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\Database\Console\Seeds;
4
 
5
use Illuminate\Console\GeneratorCommand;
6
use Illuminate\Support\Str;
7
use Symfony\Component\Console\Attribute\AsCommand;
8
 
9
#[AsCommand(name: 'make:seeder')]
10
class SeederMakeCommand extends GeneratorCommand
11
{
12
    /**
13
     * The console command name.
14
     *
15
     * @var string
16
     */
17
    protected $name = 'make:seeder';
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:seeder';
29
 
30
    /**
31
     * The console command description.
32
     *
33
     * @var string
34
     */
35
    protected $description = 'Create a new seeder class';
36
 
37
    /**
38
     * The type of class being generated.
39
     *
40
     * @var string
41
     */
42
    protected $type = 'Seeder';
43
 
44
    /**
45
     * Execute the console command.
46
     *
47
     * @return void
48
     */
49
    public function handle()
50
    {
51
        parent::handle();
52
    }
53
 
54
    /**
55
     * Get the stub file for the generator.
56
     *
57
     * @return string
58
     */
59
    protected function getStub()
60
    {
61
        return $this->resolveStubPath('/stubs/seeder.stub');
62
    }
63
 
64
    /**
65
     * Resolve the fully-qualified path to the stub.
66
     *
67
     * @param  string  $stub
68
     * @return string
69
     */
70
    protected function resolveStubPath($stub)
71
    {
72
        return is_file($customPath = $this->laravel->basePath(trim($stub, '/')))
73
            ? $customPath
74
            : __DIR__.$stub;
75
    }
76
 
77
    /**
78
     * Get the destination class path.
79
     *
80
     * @param  string  $name
81
     * @return string
82
     */
83
    protected function getPath($name)
84
    {
85
        $name = str_replace('\\', '/', Str::replaceFirst($this->rootNamespace(), '', $name));
86
 
87
        if (is_dir($this->laravel->databasePath().'/seeds')) {
88
            return $this->laravel->databasePath().'/seeds/'.$name.'.php';
89
        }
90
 
91
        return $this->laravel->databasePath().'/seeders/'.$name.'.php';
92
    }
93
 
94
    /**
95
     * Get the root namespace for the class.
96
     *
97
     * @return string
98
     */
99
    protected function rootNamespace()
100
    {
101
        return 'Database\Seeders\\';
102
    }
103
}