findOrFail() public method

Find a specific module, if there return that, otherwise throw exception.
public findOrFail ( $name ) : Module
$name
return Module
Esempio n. 1
0
 /**
  * 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.');
 }
Esempio n. 3
0
 /** @test */
 public function it_find_or_fail_throws_exception_if_module_not_found()
 {
     $this->setExpectedException(ModuleNotFoundException::class);
     $this->repository->findOrFail('something');
 }