@@ -53,7 +53,7 @@ |
||
| 53 | 53 | |
| 54 | 54 | public function runSetup() { |
| 55 | 55 | if ($this->options['foreign_key'] == null) { |
| 56 | - $this->options['foreign_key'] = Text::singularize($this->setupTable) . '_id'; |
|
| 56 | + $this->options['foreign_key'] = Text::singularize($this->setupTable).'_id'; |
|
| 57 | 57 | } |
| 58 | 58 | if ($this->options['local_key'] == null) { |
| 59 | 59 | $this->options['local_key'] = $this->setupPrimaryKey[0]; |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $filter = $junctionModel->fields($this->options['junction_foreign_key']) |
| 47 | 47 | ->filterBy($this->options['junction_local_key'], $data[$this->options['local_key']]) |
| 48 | 48 | ->fetch(); |
| 49 | - if($filter->count() == 0) { |
|
| 49 | + if ($filter->count() == 0) { |
|
| 50 | 50 | return null; |
| 51 | 51 | } |
| 52 | 52 | $foreignKeys = []; |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | // @todo throw an exception when the data doesn't have the local key |
| 58 | 58 | $query = $this->getQuery(); |
| 59 | - if($this->queryPrepared){ |
|
| 59 | + if ($this->queryPrepared) { |
|
| 60 | 60 | $query->setBoundData($this->options['foreign_key'], $foreignKeys); |
| 61 | 61 | } else { |
| 62 | 62 | $query = $this->getQuery() |
@@ -90,12 +90,12 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | if (!isset($this->options['junction_local_key'])) { |
| 92 | 92 | $this->options['junction_local_key'] = |
| 93 | - Text::singularize($this->setupTable) . '_id'; |
|
| 93 | + Text::singularize($this->setupTable).'_id'; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | if (!isset($this->options['junction_foreign_key'])) { |
| 97 | 97 | $this->options['junction_foreign_key'] = |
| 98 | - Text::singularize($foreignModel->getDBStoreInformation()['table']) . '_id'; |
|
| 98 | + Text::singularize($foreignModel->getDBStoreInformation()['table']).'_id'; |
|
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | |
@@ -110,10 +110,10 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | public function postSave(&$wrapper) { |
| 112 | 112 | $jointModelRecords = []; |
| 113 | - foreach($this->tempdata as $relatedRecord) { |
|
| 113 | + foreach ($this->tempdata as $relatedRecord) { |
|
| 114 | 114 | $data = $relatedRecord->toArray(); |
| 115 | - if(!isset($data[$this->options['foreign_key']]) || (isset($data[$this->options['foreign_key']]) && count($data) > 1)) { |
|
| 116 | - if(!$relatedRecord->save()) { |
|
| 115 | + if (!isset($data[$this->options['foreign_key']]) || (isset($data[$this->options['foreign_key']]) && count($data) > 1)) { |
|
| 116 | + if (!$relatedRecord->save()) { |
|
| 117 | 117 | throw new NibiiException("Failed to save related model {$this->options['model']}"); |
| 118 | 118 | } |
| 119 | 119 | } |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | $relationships = $this->wrapper->getDescription()->getRelationships(); |
| 157 | 157 | $presentRelationships = []; |
| 158 | 158 | |
| 159 | - foreach($relationships ?? [] as $model => $relationship) { |
|
| 160 | - if(isset($record[$model])) { |
|
| 159 | + foreach ($relationships ?? [] as $model => $relationship) { |
|
| 160 | + if (isset($record[$model])) { |
|
| 161 | 161 | $relationship->preSave($record, $record[$model]); |
| 162 | 162 | $presentRelationships[$model] = $relationship; |
| 163 | 163 | } |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | $this->runBehaviours('postSaveCallback', [$record, $keyValue]); |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - foreach($presentRelationships as $model => $relationship) { |
|
| 182 | + foreach ($presentRelationships as $model => $relationship) { |
|
| 183 | 183 | $relationship->postSave($record); |
| 184 | 184 | } |
| 185 | 185 | |