SessionTableCommand.php
TLDR
This file contains the SessionTableCommand
class, which is a command that creates a migration for a session database table.
Classes
SessionTableCommand
The SessionTableCommand
class extends the MigrationGeneratorCommand
class and is responsible for creating a migration for the session database table. It is used as a command in the console.
The class has the following properties:
-
$name
- The console command name. -
$aliases
- The console command name aliases. -
$description
- The console command description.
The class has the following methods:
-
migrationTableName()
- Returns the name of the migration table. -
migrationStubFile()
- Returns the path to the migration stub file. -
migrationExists($table)
- Determines whether a migration for the given table already exists.
<?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')]
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;
}
}