|
@@ 26-28 (lines=3) @@
|
| 23 |
|
*/ |
| 24 |
|
public function getRelation($name) |
| 25 |
|
{ |
| 26 |
|
if (!$this->hasRelation($name)) { |
| 27 |
|
throw new InvalidConfigException('Model ' . static::class . ' does not have relation ' . $name); |
| 28 |
|
} |
| 29 |
|
|
| 30 |
|
return $this->relations()[$name]; |
| 31 |
|
} |
|
@@ 35-37 (lines=3) @@
|
| 32 |
|
|
| 33 |
|
public function getAttribute($name) |
| 34 |
|
{ |
| 35 |
|
if (!$this->hasAttribute($name)) { |
| 36 |
|
throw new InvalidConfigException('Attribute ' . $name . ' is not available within ' . static::class); |
| 37 |
|
} |
| 38 |
|
|
| 39 |
|
$className = $this->attributes()[$name]; |
| 40 |
|
return new $className; |