| @@ 373-379 (lines=7) @@ | ||
| 370 | $relations = explode('.', $path); |
|
| 371 | $count = count($relations); |
|
| 372 | ||
| 373 | if ($count === 1) { |
|
| 374 | $attribute = $model->getAttribute($this->getModelAttributeKey()); |
|
| 375 | ||
| 376 | if (! empty($attribute) or is_null($value)) { |
|
| 377 | return $attribute; |
|
| 378 | } |
|
| 379 | } |
|
| 380 | ||
| 381 | foreach ($relations as $relation) { |
|
| 382 | if ($model->{$relation} instanceof Model) { |
|
| @@ 387-393 (lines=7) @@ | ||
| 384 | continue; |
|
| 385 | } |
|
| 386 | ||
| 387 | if ($count === 2) { |
|
| 388 | $attribute = $model->getAttribute($relation); |
|
| 389 | ||
| 390 | if (! empty($attribute) or is_null($value)) { |
|
| 391 | return $attribute; |
|
| 392 | } |
|
| 393 | } |
|
| 394 | ||
| 395 | if (is_null($this->getDefaultValue())) { |
|
| 396 | throw new LogicException("Can not fetch value for field '{$path}'. Probably relation definition is incorrect"); |
|