| Conditions | 5 |
| Paths | 16 |
| Total Lines | 23 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php namespace Xethron\MigrationsGenerator\Syntax; |
||
| 15 | protected function getItem(array $foreignKey) |
||
| 16 | { |
||
| 17 | $value = $foreignKey['field']; |
||
| 18 | if ( ! empty($foreignKey['name'])) { |
||
| 19 | $value .= "', '". $foreignKey['name']; |
||
| 20 | } |
||
| 21 | $output = sprintf( |
||
| 22 | "\$table->foreign('%s')->references('%s')->on('%s')", |
||
| 23 | $value, |
||
| 24 | $foreignKey['references'], |
||
| 25 | $foreignKey['on'] |
||
| 26 | ); |
||
| 27 | if ($foreignKey['onUpdate']) { |
||
| 28 | $output .= sprintf("->onUpdate('%s')", $foreignKey['onUpdate']); |
||
| 29 | } |
||
| 30 | if ($foreignKey['onDelete']) { |
||
| 31 | $output .= sprintf("->onDelete('%s')", $foreignKey['onDelete']); |
||
| 32 | } |
||
| 33 | if (isset($foreignKey['decorators'])) { |
||
| 34 | $output .= $this->addDecorators($foreignKey['decorators']); |
||
| 35 | } |
||
| 36 | return $output . ';'; |
||
| 37 | } |
||
| 38 | |||
| 40 |