АП
Size: a a a
АП
T0
АП
CC
T0
АП
АП
А
CC
АП
CC
АП
АП
АП
АП
АП
A
АП
public function addConstraints()
{
if (static::$constraints) {
$query = $this->getRelationQuery();
$query->where($this->foreignKey, '=', $this->getParentKey());
$query->whereNotNull($this->foreignKey);
}
}
public function getParentKey()
{
return $this->parent->getAttribute($this->localKey);
}
АП
public function getAttribute($key)
{
if (! $key) {
return;
}
// If the attribute exists in the attribute array or has a "get" mutator we will
// get the attribute's value. Otherwise, we will proceed as if the developers
// are asking for a relationship's value. This covers both types of values.
if (array_key_exists($key, $this->attributes) ||
array_key_exists($key, $this->casts) ||
$this->hasGetMutator($key) ||
$this->isClassCastable($key)) {
return $this->getAttributeValue($key);
}
// Here we will determine if the model base class itself contains this given key
// since we don't want to treat any of those methods as relationships because
// they are all intended as helper methods and none of these are relations.
if (method_exists(self::class, $key)) {
return;
}
return $this->getRelationValue($key);
}