| Total Complexity | 9 |
| Total Lines | 26 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class ParentType extends SingleType |
||
| 8 | {
|
||
| 9 | protected $isParent = true; |
||
| 10 | |||
| 11 | public function getSchema() |
||
| 12 | {
|
||
| 13 | $schema = ""; |
||
| 14 | $parentTable = $this->hasSelfParent() ? $this->getParentModule() : $this->typeOption; |
||
| 15 | $schema .= "\$table->bigInteger('".$this->getForeignKey()."')->unsigned()->nullable();".PHP_EOL.$this->getTabs(3);
|
||
| 16 | $schema .= "\$table->foreign('".$this->getForeignKey()."')->references('id')->on('$parentTable')->onDelete('set null');".PHP_EOL;
|
||
| 17 | return $schema; |
||
| 18 | } |
||
| 19 | |||
| 20 | public function getPivot() |
||
| 21 | {
|
||
| 22 | return ($this->typeOption == $this->getParentModule() || $this->typeOption == "self") ? $this->getParentModel() : ucfirst(Str::singular(Str::camel($this->typeOption))); |
||
| 23 | } |
||
| 24 | |||
| 25 | public function getRelatedModel() |
||
| 26 | {
|
||
| 27 | return $this->getChildModel(); |
||
| 28 | } |
||
| 29 | |||
| 30 | public function getChildModel() |
||
| 33 | } |
||
| 34 | } |
||
| 35 |