Find a specific module, if there return that, otherwise throw exception.
public findOrFail ( $name ) : |
||
$name | ||
return |
/** * Execute the console command. * * @return mixed */ public function fire() { $this->module = $this->laravel['modules']; $name = $this->argument('module'); if ($name) { $module = $this->module->findOrFail($name); return $this->migrate($module); } foreach ($this->module->getOrdered($this->option('direction')) as $module) { $this->line('Running for module: <info>' . $module->getName() . '</info>'); $this->migrate($module); } }
/** * Rollback migration from the specified module. * * @param $module */ public function reset($module) { if (is_string($module)) { $module = $this->module->findOrFail($module); } $migrator = new Migrator($module); $database = $this->option('database'); if (!empty($database)) { $migrator->setDatabase($database); } $migrated = $migrator->reset(); if (count($migrated)) { foreach ($migrated as $migration) { $this->line("Rollback: <info>{$migration}</info>"); } return; } $this->comment('Nothing to rollback.'); }
/** @test */ public function it_find_or_fail_throws_exception_if_module_not_found() { $this->setExpectedException(ModuleNotFoundException::class); $this->repository->findOrFail('something'); }