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\Notifications\Console;
4
 
5
use Illuminate\Console\Command;
6
use Illuminate\Filesystem\Filesystem;
7
use Illuminate\Support\Composer;
8
use Symfony\Component\Console\Attribute\AsCommand;
9
 
10
#[AsCommand(name: 'notifications:table')]
11
class NotificationTableCommand extends Command
12
{
13
    /**
14
     * The console command name.
15
     *
16
     * @var string
17
     */
18
    protected $name = 'notifications:table';
19
 
20
    /**
21
     * The name of the console command.
22
     *
23
     * This name is used to identify the command during lazy loading.
24
     *
25
     * @var string|null
26
     *
27
     * @deprecated
28
     */
29
    protected static $defaultName = 'notifications:table';
30
 
31
    /**
32
     * The console command description.
33
     *
34
     * @var string
35
     */
36
    protected $description = 'Create a migration for the notifications table';
37
 
38
    /**
39
     * The filesystem instance.
40
     *
41
     * @var \Illuminate\Filesystem\Filesystem
42
     */
43
    protected $files;
44
 
45
    /**
46
     * @var \Illuminate\Support\Composer
47
     */
48
    protected $composer;
49
 
50
    /**
51
     * Create a new notifications table command instance.
52
     *
53
     * @param  \Illuminate\Filesystem\Filesystem  $files
54
     * @param  \Illuminate\Support\Composer  $composer
55
     * @return void
56
     */
57
    public function __construct(Filesystem $files, Composer $composer)
58
    {
59
        parent::__construct();
60
 
61
        $this->files = $files;
62
        $this->composer = $composer;
63
    }
64
 
65
    /**
66
     * Execute the console command.
67
     *
68
     * @return void
69
     */
70
    public function handle()
71
    {
72
        $fullPath = $this->createBaseMigration();
73
 
74
        $this->files->put($fullPath, $this->files->get(__DIR__.'/stubs/notifications.stub'));
75
 
76
        $this->components->info('Migration created successfully.');
77
 
78
        $this->composer->dumpAutoloads();
79
    }
80
 
81
    /**
82
     * Create a base migration file for the notifications.
83
     *
84
     * @return string
85
     */
86
    protected function createBaseMigration()
87
    {
88
        $name = 'create_notifications_table';
89
 
90
        $path = $this->laravel->databasePath().'/migrations';
91
 
92
        return $this->laravel['migration.creator']->create($name, $path);
93
    }
94
}