/** * Get all migrations. * * @param StructuredStatusInterface $status * * @return Card */ public function getAll(StructuredStatusInterface $status) { $report = $status->generateReport(); $idle = $report->getIdle(); $unknown = $report->getUnknown(); $ran = $report->getRan(); return new Card([], [new CardHeader([], 'All Migrations'), new SimpleTable(['-', 'Status', 'Name'], Std::map(function ($name) use($idle, $unknown, $ran) { if (in_array($name, $idle)) { return [new Italic(['class' => ['fa', 'fa-circle-o', 'text-warning']]), 'Pending', $name]; } elseif (in_array($name, $unknown)) { return [new Italic(['class' => ['fa', 'fa-times-circle', 'text-danger']]), 'Exotic', $name]; } elseif (in_array($name, $ran)) { return [new Italic(['class' => ['fa', 'fa-check-circle', 'text-success']]), 'Ran', $name]; } return [new Italic(['class' => ['fa', 'fa-circle-o']]), '???', $name]; }, Std::concat($report->getMigrations(), $report->getUnknown())))]); }
/** * Execute the console command. */ public function fire() { $report = $this->status->generateReport(); $ran = $report->getRan(); $rows = []; foreach ($report->getMigrations() as $migration) { if (in_array($migration, $ran)) { $rows[] = ['<info>✔ Yes</info>', $migration]; } else { $rows[] = ['<fg=red>✗ No</fg=red>', $migration]; } } foreach ($report->getUnknown() as $migration) { $rows[] = ['<comment>✗ Exotic</comment>', $migration]; } if (count($rows) > 0) { $this->table(['Status', 'Migration'], $rows); if (count($report->getUnknown()) > 0) { $this->line('<comment>Warning: Some "exotic" (unknown)' . ' migrations were detected. Check your batch classes' . '</comment>'); } } else { $this->error('No migrations found'); } }
/** * Render the object into a string. * * @return mixed */ public function render() { return new Row([], [new Column(['medium' => 6, 'class' => 'text-xs-center'], [new Card([], new CardBlock([], [new HeaderOne(['class' => 'display-3'], vsprintf('%d', [count($this->report->getRan())])), new Paragraph([], new Small(['class' => 'text-uppercase text-muted'], ['Migrations ran so far']))]))]), new Column(['medium' => 6, 'class' => 'text-xs-center'], [new Card([], new CardBlock([], [new HeaderOne(['class' => 'display-3'], vsprintf('%d', [count($this->report->getIdle())])), new Paragraph([], new Small(['class' => 'text-uppercase text-muted'], ['Pending to be ran']))]))])]); }