forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSessionTableCommand.php
68 lines (59 loc) · 1.57 KB
/
SessionTableCommand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace Illuminate\Session\Console;
use Illuminate\Console\MigrationGeneratorCommand;
use Symfony\Component\Console\Attribute\AsCommand;
use function Illuminate\Filesystem\join_paths;
#[AsCommand(name: 'make:session-table', aliases: ['session:table'])]
class SessionTableCommand extends MigrationGeneratorCommand
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'make:session-table';
/**
* The console command name aliases.
*
* @var array
*/
protected $aliases = ['session:table'];
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a migration for the session database table';
/**
* Get the migration table name.
*
* @return string
*/
protected function migrationTableName()
{
return 'sessions';
}
/**
* Get the path to the migration stub file.
*
* @return string
*/
protected function migrationStubFile()
{
return __DIR__.'/stubs/database.stub';
}
/**
* Determine whether a migration for the table already exists.
*
* @param string $table
* @return bool
*/
protected function migrationExists($table)
{
return count($this->files->glob(sprintf(
'{%s,%s}',
join_paths($this->laravel->databasePath('migrations'), '*_*_*_*_create_'.$table.'_table.php'),
join_paths($this->laravel->databasePath('migrations'), '0001_01_01_000000_create_users_table.php'),
))) !== 0;
}
}