Total Complexity | 4 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | class Migration extends BaseGenerator implements GeneratorInterface |
||
8 | { |
||
9 | protected static $counter = 0; |
||
10 | |||
11 | public function generate(Module $module) |
||
12 | { |
||
13 | $this->setModule($module); |
||
14 | |||
15 | $migrationTemplate = $this->buildTemplate('Migration', [ |
||
16 | '{{modelName}}' => $module->getModelName(), |
||
17 | '{{modelNamePlural}}' => $module->getModelNamePlural(), |
||
18 | '{{moduleName}}' => $module->getModuleName(), |
||
19 | '{{modelTableSchema}}' => $this->getSchema() |
||
20 | ]); |
||
21 | |||
22 | $dateSuffix = (int)date('His') + ++self::$counter; |
||
23 | file_put_contents(database_path() . "/migrations/" . date('Y_m_d_') . $dateSuffix . "_create_" . $module->getModuleName() . "_table.php", $migrationTemplate); |
||
24 | } |
||
25 | |||
26 | protected function getSchema() |
||
43 | } |
||
44 | } |
||
45 |