Added vendor/ directory for Composer's installed files
This commit is contained in:
17
vendor/illuminate/database/Console/Migrations/BaseCommand.php
vendored
Executable file
17
vendor/illuminate/database/Console/Migrations/BaseCommand.php
vendored
Executable file
@ -0,0 +1,17 @@
|
||||
<?php namespace Illuminate\Database\Console\Migrations;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class BaseCommand extends Command {
|
||||
|
||||
/**
|
||||
* Get the path to the migration directory.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getMigrationPath()
|
||||
{
|
||||
return $this->laravel->databasePath().'/migrations';
|
||||
}
|
||||
|
||||
}
|
69
vendor/illuminate/database/Console/Migrations/InstallCommand.php
vendored
Executable file
69
vendor/illuminate/database/Console/Migrations/InstallCommand.php
vendored
Executable file
@ -0,0 +1,69 @@
|
||||
<?php namespace Illuminate\Database\Console\Migrations;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Illuminate\Database\Migrations\MigrationRepositoryInterface;
|
||||
|
||||
class InstallCommand extends Command {
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'migrate:install';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create the migration repository';
|
||||
|
||||
/**
|
||||
* The repository instance.
|
||||
*
|
||||
* @var \Illuminate\Database\Migrations\MigrationRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* Create a new migration install command instance.
|
||||
*
|
||||
* @param \Illuminate\Database\Migrations\MigrationRepositoryInterface $repository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(MigrationRepositoryInterface $repository)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
$this->repository->setSource($this->input->getOption('database'));
|
||||
|
||||
$this->repository->createRepository();
|
||||
|
||||
$this->info("Migration table created successfully.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return array(
|
||||
array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
129
vendor/illuminate/database/Console/Migrations/MigrateCommand.php
vendored
Executable file
129
vendor/illuminate/database/Console/Migrations/MigrateCommand.php
vendored
Executable file
@ -0,0 +1,129 @@
|
||||
<?php namespace Illuminate\Database\Console\Migrations;
|
||||
|
||||
use Illuminate\Console\ConfirmableTrait;
|
||||
use Illuminate\Database\Migrations\Migrator;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class MigrateCommand extends BaseCommand {
|
||||
|
||||
use ConfirmableTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'migrate';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Run the database migrations';
|
||||
|
||||
/**
|
||||
* The migrator instance.
|
||||
*
|
||||
* @var \Illuminate\Database\Migrations\Migrator
|
||||
*/
|
||||
protected $migrator;
|
||||
|
||||
/**
|
||||
* Create a new migration command instance.
|
||||
*
|
||||
* @param \Illuminate\Database\Migrations\Migrator $migrator
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Migrator $migrator)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->migrator = $migrator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
if ( ! $this->confirmToProceed()) return;
|
||||
|
||||
$this->prepareDatabase();
|
||||
|
||||
// The pretend option can be used for "simulating" the migration and grabbing
|
||||
// the SQL queries that would fire if the migration were to be run against
|
||||
// a database for real, which is helpful for double checking migrations.
|
||||
$pretend = $this->input->getOption('pretend');
|
||||
|
||||
// Next, we will check to see if a path option has been defined. If it has
|
||||
// we will use the path relative to the root of this installation folder
|
||||
// so that migrations may be run for any path within the applications.
|
||||
if ( ! is_null($path = $this->input->getOption('path')))
|
||||
{
|
||||
$path = $this->laravel->basePath().'/'.$path;
|
||||
}
|
||||
else
|
||||
{
|
||||
$path = $this->getMigrationPath();
|
||||
}
|
||||
|
||||
$this->migrator->run($path, $pretend);
|
||||
|
||||
// Once the migrator has run we will grab the note output and send it out to
|
||||
// the console screen, since the migrator itself functions without having
|
||||
// any instances of the OutputInterface contract passed into the class.
|
||||
foreach ($this->migrator->getNotes() as $note)
|
||||
{
|
||||
$this->output->writeln($note);
|
||||
}
|
||||
|
||||
// Finally, if the "seed" option has been given, we will re-run the database
|
||||
// seed task to re-populate the database, which is convenient when adding
|
||||
// a migration and a seed at the same time, as it is only this command.
|
||||
if ($this->input->getOption('seed'))
|
||||
{
|
||||
$this->call('db:seed', ['--force' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the migration database for running.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareDatabase()
|
||||
{
|
||||
$this->migrator->setConnection($this->input->getOption('database'));
|
||||
|
||||
if ( ! $this->migrator->repositoryExists())
|
||||
{
|
||||
$options = array('--database' => $this->input->getOption('database'));
|
||||
|
||||
$this->call('migrate:install', $options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return array(
|
||||
array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'),
|
||||
|
||||
array('force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'),
|
||||
|
||||
array('path', null, InputOption::VALUE_OPTIONAL, 'The path of migrations files to be executed.'),
|
||||
|
||||
array('pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'),
|
||||
|
||||
array('seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
120
vendor/illuminate/database/Console/Migrations/MigrateMakeCommand.php
vendored
Executable file
120
vendor/illuminate/database/Console/Migrations/MigrateMakeCommand.php
vendored
Executable file
@ -0,0 +1,120 @@
|
||||
<?php namespace Illuminate\Database\Console\Migrations;
|
||||
|
||||
use Illuminate\Foundation\Composer;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Illuminate\Database\Migrations\MigrationCreator;
|
||||
|
||||
class MigrateMakeCommand extends BaseCommand {
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'make:migration';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new migration file';
|
||||
|
||||
/**
|
||||
* The migration creator instance.
|
||||
*
|
||||
* @var \Illuminate\Database\Migrations\MigrationCreator
|
||||
*/
|
||||
protected $creator;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Foundation\Composer
|
||||
*/
|
||||
protected $composer;
|
||||
|
||||
/**
|
||||
* Create a new migration install command instance.
|
||||
*
|
||||
* @param \Illuminate\Database\Migrations\MigrationCreator $creator
|
||||
* @param \Illuminate\Foundation\Composer $composer
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(MigrationCreator $creator, Composer $composer)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->creator = $creator;
|
||||
$this->composer = $composer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
// It's possible for the developer to specify the tables to modify in this
|
||||
// schema operation. The developer may also specify if this table needs
|
||||
// to be freshly created so we can create the appropriate migrations.
|
||||
$name = $this->input->getArgument('name');
|
||||
|
||||
$table = $this->input->getOption('table');
|
||||
|
||||
$create = $this->input->getOption('create');
|
||||
|
||||
if ( ! $table && is_string($create)) $table = $create;
|
||||
|
||||
// Now we are ready to write the migration out to disk. Once we've written
|
||||
// the migration out, we will dump-autoload for the entire framework to
|
||||
// make sure that the migrations are registered by the class loaders.
|
||||
$this->writeMigration($name, $table, $create);
|
||||
|
||||
$this->composer->dumpAutoloads();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the migration file to disk.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $table
|
||||
* @param bool $create
|
||||
* @return string
|
||||
*/
|
||||
protected function writeMigration($name, $table, $create)
|
||||
{
|
||||
$path = $this->getMigrationPath();
|
||||
|
||||
$file = pathinfo($this->creator->create($name, $path, $table, $create), PATHINFO_FILENAME);
|
||||
|
||||
$this->line("<info>Created Migration:</info> $file");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return array(
|
||||
array('name', InputArgument::REQUIRED, 'The name of the migration'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return array(
|
||||
array('create', null, InputOption::VALUE_OPTIONAL, 'The table to be created.'),
|
||||
|
||||
array('table', null, InputOption::VALUE_OPTIONAL, 'The table to migrate.'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
96
vendor/illuminate/database/Console/Migrations/RefreshCommand.php
vendored
Executable file
96
vendor/illuminate/database/Console/Migrations/RefreshCommand.php
vendored
Executable file
@ -0,0 +1,96 @@
|
||||
<?php namespace Illuminate\Database\Console\Migrations;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Console\ConfirmableTrait;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class RefreshCommand extends Command {
|
||||
|
||||
use ConfirmableTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'migrate:refresh';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Reset and re-run all migrations';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
if ( ! $this->confirmToProceed()) return;
|
||||
|
||||
$database = $this->input->getOption('database');
|
||||
|
||||
$force = $this->input->getOption('force');
|
||||
|
||||
$this->call('migrate:reset', array(
|
||||
'--database' => $database, '--force' => $force,
|
||||
));
|
||||
|
||||
// The refresh command is essentially just a brief aggregate of a few other of
|
||||
// the migration commands and just provides a convenient wrapper to execute
|
||||
// them in succession. We'll also see if we need to re-seed the database.
|
||||
$this->call('migrate', array(
|
||||
'--database' => $database, '--force' => $force,
|
||||
));
|
||||
|
||||
if ($this->needsSeeding())
|
||||
{
|
||||
$this->runSeeder($database);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the developer has requested database seeding.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function needsSeeding()
|
||||
{
|
||||
return $this->option('seed') || $this->option('seeder');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the database seeder command.
|
||||
*
|
||||
* @param string $database
|
||||
* @return void
|
||||
*/
|
||||
protected function runSeeder($database)
|
||||
{
|
||||
$class = $this->option('seeder') ?: 'DatabaseSeeder';
|
||||
|
||||
$this->call('db:seed', array('--database' => $database, '--class' => $class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return array(
|
||||
array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'),
|
||||
|
||||
array('force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'),
|
||||
|
||||
array('seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'),
|
||||
|
||||
array('seeder', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder.'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
86
vendor/illuminate/database/Console/Migrations/ResetCommand.php
vendored
Executable file
86
vendor/illuminate/database/Console/Migrations/ResetCommand.php
vendored
Executable file
@ -0,0 +1,86 @@
|
||||
<?php namespace Illuminate\Database\Console\Migrations;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Console\ConfirmableTrait;
|
||||
use Illuminate\Database\Migrations\Migrator;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class ResetCommand extends Command {
|
||||
|
||||
use ConfirmableTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'migrate:reset';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Rollback all database migrations';
|
||||
|
||||
/**
|
||||
* The migrator instance.
|
||||
*
|
||||
* @var \Illuminate\Database\Migrations\Migrator
|
||||
*/
|
||||
protected $migrator;
|
||||
|
||||
/**
|
||||
* Create a new migration rollback command instance.
|
||||
*
|
||||
* @param \Illuminate\Database\Migrations\Migrator $migrator
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Migrator $migrator)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->migrator = $migrator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
if ( ! $this->confirmToProceed()) return;
|
||||
|
||||
$this->migrator->setConnection($this->input->getOption('database'));
|
||||
|
||||
$pretend = $this->input->getOption('pretend');
|
||||
|
||||
$this->migrator->reset($pretend);
|
||||
|
||||
// Once the migrator has run we will grab the note output and send it out to
|
||||
// the console screen, since the migrator itself functions without having
|
||||
// any instances of the OutputInterface contract passed into the class.
|
||||
foreach ($this->migrator->getNotes() as $note)
|
||||
{
|
||||
$this->output->writeln($note);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return array(
|
||||
array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'),
|
||||
|
||||
array('force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'),
|
||||
|
||||
array('pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
86
vendor/illuminate/database/Console/Migrations/RollbackCommand.php
vendored
Executable file
86
vendor/illuminate/database/Console/Migrations/RollbackCommand.php
vendored
Executable file
@ -0,0 +1,86 @@
|
||||
<?php namespace Illuminate\Database\Console\Migrations;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Console\ConfirmableTrait;
|
||||
use Illuminate\Database\Migrations\Migrator;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class RollbackCommand extends Command {
|
||||
|
||||
use ConfirmableTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'migrate:rollback';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Rollback the last database migration';
|
||||
|
||||
/**
|
||||
* The migrator instance.
|
||||
*
|
||||
* @var \Illuminate\Database\Migrations\Migrator
|
||||
*/
|
||||
protected $migrator;
|
||||
|
||||
/**
|
||||
* Create a new migration rollback command instance.
|
||||
*
|
||||
* @param \Illuminate\Database\Migrations\Migrator $migrator
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Migrator $migrator)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->migrator = $migrator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
if ( ! $this->confirmToProceed()) return;
|
||||
|
||||
$this->migrator->setConnection($this->input->getOption('database'));
|
||||
|
||||
$pretend = $this->input->getOption('pretend');
|
||||
|
||||
$this->migrator->rollback($pretend);
|
||||
|
||||
// Once the migrator has run we will grab the note output and send it out to
|
||||
// the console screen, since the migrator itself functions without having
|
||||
// any instances of the OutputInterface contract passed into the class.
|
||||
foreach ($this->migrator->getNotes() as $note)
|
||||
{
|
||||
$this->output->writeln($note);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return array(
|
||||
array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'),
|
||||
|
||||
array('force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'),
|
||||
|
||||
array('pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
82
vendor/illuminate/database/Console/Migrations/StatusCommand.php
vendored
Executable file
82
vendor/illuminate/database/Console/Migrations/StatusCommand.php
vendored
Executable file
@ -0,0 +1,82 @@
|
||||
<?php namespace Illuminate\Database\Console\Migrations;
|
||||
|
||||
use Illuminate\Database\Migrations\Migrator;
|
||||
|
||||
class StatusCommand extends BaseCommand {
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'migrate:status';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Show the status of each migration';
|
||||
|
||||
/**
|
||||
* The migrator instance.
|
||||
*
|
||||
* @var \Illuminate\Database\Migrations\Migrator
|
||||
*/
|
||||
protected $migrator;
|
||||
|
||||
/**
|
||||
* Create a new migration rollback command instance.
|
||||
*
|
||||
* @param \Illuminate\Database\Migrations\Migrator $migrator
|
||||
* @return \Illuminate\Database\Console\Migrations\StatusCommand
|
||||
*/
|
||||
public function __construct(Migrator $migrator)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->migrator = $migrator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
if ( ! $this->migrator->repositoryExists())
|
||||
{
|
||||
return $this->error('No migrations found.');
|
||||
}
|
||||
|
||||
$ran = $this->migrator->getRepository()->getRan();
|
||||
|
||||
$migrations = [];
|
||||
|
||||
foreach ($this->getAllMigrationFiles() as $migration)
|
||||
{
|
||||
$migrations[] = in_array($migration, $ran) ? ['<info>Y</info>', $migration] : ['<fg=red>N</fg=red>', $migration];
|
||||
}
|
||||
|
||||
if (count($migrations) > 0)
|
||||
{
|
||||
$this->table(['Ran?', 'Migration'], $migrations);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error('No migrations found');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the migration files.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getAllMigrationFiles()
|
||||
{
|
||||
return $this->migrator->getMigrationFiles($this->getMigrationPath());
|
||||
}
|
||||
|
||||
}
|
100
vendor/illuminate/database/Console/SeedCommand.php
vendored
Executable file
100
vendor/illuminate/database/Console/SeedCommand.php
vendored
Executable file
@ -0,0 +1,100 @@
|
||||
<?php namespace Illuminate\Database\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Console\ConfirmableTrait;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Illuminate\Database\ConnectionResolverInterface as Resolver;
|
||||
|
||||
class SeedCommand extends Command {
|
||||
|
||||
use ConfirmableTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'db:seed';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Seed the database with records';
|
||||
|
||||
/**
|
||||
* The connection resolver instance.
|
||||
*
|
||||
* @var \Illuminate\Database\ConnectionResolverInterface
|
||||
*/
|
||||
protected $resolver;
|
||||
|
||||
/**
|
||||
* Create a new database seed command instance.
|
||||
*
|
||||
* @param \Illuminate\Database\ConnectionResolverInterface $resolver
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Resolver $resolver)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->resolver = $resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
if ( ! $this->confirmToProceed()) return;
|
||||
|
||||
$this->resolver->setDefaultConnection($this->getDatabase());
|
||||
|
||||
$this->getSeeder()->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a seeder instance from the container.
|
||||
*
|
||||
* @return \Illuminate\Database\Seeder
|
||||
*/
|
||||
protected function getSeeder()
|
||||
{
|
||||
$class = $this->laravel->make($this->input->getOption('class'));
|
||||
|
||||
return $class->setContainer($this->laravel)->setCommand($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the database connection to use.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getDatabase()
|
||||
{
|
||||
$database = $this->input->getOption('database');
|
||||
|
||||
return $database ?: $this->laravel['config']['database.default'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return array(
|
||||
array('class', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder', 'DatabaseSeeder'),
|
||||
|
||||
array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to seed'),
|
||||
|
||||
array('force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user