| Conditions | 1 |
| Paths | 1 |
| Total Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function execute($request) |
||
| 19 | { |
||
| 20 | $source = app($request['source'])->getTable(); |
||
| 21 | $target = app($request['target'])->getTable(); |
||
| 22 | $foreignKey = $this->getForeignKey($request); |
||
| 23 | $stub = __DIR__ . '/../../../resources/stubs/migration/relation.stub'; |
||
| 24 | $this->filename = 'database/migrations/' |
||
| 25 | . date('Y_m_d_His') |
||
| 26 | . "_create_{$source}_{$target}_relation.php"; |
||
| 27 | |||
| 28 | (new StubWriter(base_path($this->filename), $stub))->write([ |
||
| 29 | '$column$' => "\$table->foreign('$foreignKey')->references('{$this->getLocalKey($request)}')->on('$target');", |
||
| 30 | '$classname$' => 'Create' . ucfirst(Str::camel($source)) . ucfirst(Str::camel($target)) . 'Relation', |
||
| 31 | '$foreignKey$' => $foreignKey, |
||
| 32 | '$source$' => $source, |
||
| 33 | '$target$' => $target, |
||
| 34 | ]); |
||
| 35 | } |
||
| 36 | } |
||
| 37 |