public function rollback($paths = [], array $options = [])
{
$this->notes = [];
$rolledBack = [];
$migrations = $this->getRanMigrations();
$files = $this->getMigrationFiles($paths);
$count = count($migrations);
if ($count === 0) {
$this->note('<info>Nothing to rollback.</info>');
} else {
$this->requireFiles($files);
$steps = Arr::get($options, 'step', 0);
if ($steps == 0) {
$steps = 1;
}
$lastBatch = $this->repository->getLastBatchNumber();
$stepDown = false;
foreach ($migrations as $migration) {
$migration = (object) $migration;
if ($lastBatch > $migration->batch && $stepDown) {
$steps--;
$stepDown = false;
$lastBatch = $migration->batch;
}
if ($steps <= 0) {
break;
}
if (Arr::exists($files, $migration->migration)) {
$rolledBack[] = $files[$migration->migration];
$stepDown = true;
$this->runDown($files[$migration->migration], $migration, Arr::get($options, 'pretend', false));
}
}
}
return $rolledBack;
}