| @@ 9-31 (lines=23) @@ | ||
| 6 | ||
| 7 | use App\Lib\Slime\Console\SlimeCommand; |
|
| 8 | ||
| 9 | class MigrateCommand extends SlimeCommand |
|
| 10 | { |
|
| 11 | const MIGRATIONS_PATH = 'database/migrations'; |
|
| 12 | ||
| 13 | /** |
|
| 14 | * @return int |
|
| 15 | */ |
|
| 16 | public function run() |
|
| 17 | { |
|
| 18 | $files = glob(self::MIGRATIONS_PATH . '/*.php'); |
|
| 19 | $this->runMigrations($files); |
|
| 20 | } |
|
| 21 | ||
| 22 | private function runMigrations($files) |
|
| 23 | { |
|
| 24 | foreach ($files as $file) { |
|
| 25 | require_once($file); |
|
| 26 | $class = basename($file, '.php'); |
|
| 27 | $obj = new $class; |
|
| 28 | $obj->run(); |
|
| 29 | } |
|
| 30 | } |
|
| 31 | } |
|
| @@ 9-31 (lines=23) @@ | ||
| 6 | ||
| 7 | use App\Lib\Slime\Console\SlimeCommand; |
|
| 8 | ||
| 9 | class SeedCommand extends SlimeCommand |
|
| 10 | { |
|
| 11 | const SEED_PATH = 'database/seeds'; |
|
| 12 | ||
| 13 | /** |
|
| 14 | * @return int |
|
| 15 | */ |
|
| 16 | public function run() |
|
| 17 | { |
|
| 18 | $files = glob(self::SEED_PATH . '/*.php'); |
|
| 19 | $this->runSeeders($files); |
|
| 20 | } |
|
| 21 | ||
| 22 | private function runSeeders($files) |
|
| 23 | { |
|
| 24 | foreach ($files as $file) { |
|
| 25 | require_once($file); |
|
| 26 | $class = basename($file, '.php'); |
|
| 27 | $obj = new $class; |
|
| 28 | $obj->run(); |
|
| 29 | } |
|
| 30 | } |
|
| 31 | } |
|