src/services/traits/Model.php 1 location
|
@@ 59-74 (lines=16) @@
|
| 56 |
|
* @param bool $mirrorScenario |
| 57 |
|
* @return Record |
| 58 |
|
*/ |
| 59 |
|
public function toRecord(BaseModel $model, bool $mirrorScenario = true): Record |
| 60 |
|
{ |
| 61 |
|
|
| 62 |
|
if (!$record = $this->findRecordByModel($model)) { |
| 63 |
|
|
| 64 |
|
// Create new record |
| 65 |
|
$record = $this->createRecord(); |
| 66 |
|
|
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
// Populate the record attributes |
| 70 |
|
$this->transferToRecord($model, $record, $mirrorScenario); |
| 71 |
|
|
| 72 |
|
return $record; |
| 73 |
|
|
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
} |
| 77 |
|
|
src/services/traits/ModelByString.php 1 location
|
@@ 285-298 (lines=14) @@
|
| 282 |
|
* @param bool $mirrorScenario |
| 283 |
|
* @return Record |
| 284 |
|
*/ |
| 285 |
|
protected function toRecordByString(BaseModel $model, bool $mirrorScenario = true): Record |
| 286 |
|
{ |
| 287 |
|
|
| 288 |
|
// Get record |
| 289 |
|
if (!$record = $this->findRecordByString($this->stringValue($model))) { |
| 290 |
|
return null; |
| 291 |
|
} |
| 292 |
|
|
| 293 |
|
// Populate the record attributes |
| 294 |
|
$this->transferToRecord($model, $record, $mirrorScenario); |
| 295 |
|
|
| 296 |
|
return $record; |
| 297 |
|
|
| 298 |
|
} |
| 299 |
|
|
| 300 |
|
/******************************************* |
| 301 |
|
* EXCEPTIONS |