eee
This commit is contained in:
+10
-7
@@ -691,13 +691,16 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
|
||||
*/
|
||||
public function __set(string $name, mixed $value): void
|
||||
{
|
||||
if ($this->hasRelateMethod($name, 'set')) {
|
||||
$this->{'set' . ucfirst($name)}($value);
|
||||
$prefix = 'set' . ucfirst($name);
|
||||
if (method_exists($name, $prefix)) {
|
||||
$this->{$prefix}($value);
|
||||
return;
|
||||
}
|
||||
|
||||
$method = $prefix . 'Attribute';
|
||||
if (method_exists($this, $method)) {
|
||||
$this->_attributes[$name] = $this->{$method} ($value);
|
||||
} else {
|
||||
$method = 'set' . ucfirst($name) . 'Attribute';
|
||||
if (method_exists($this, $method)) {
|
||||
$value = $this->{$method} ($value);
|
||||
}
|
||||
$this->_attributes[$name] = $value;
|
||||
}
|
||||
}
|
||||
@@ -711,7 +714,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
|
||||
public function __get(string $name): mixed
|
||||
{
|
||||
$value = $this->_attributes[$name] ?? NULL;
|
||||
if (!$this->hasRelateMethod($name)) {
|
||||
if (!method_exists($this, 'get' . ucfirst($name))) {
|
||||
return $this->withPropertyOverride($name, $value);
|
||||
} else {
|
||||
return $this->withRelate($name);
|
||||
|
||||
Reference in New Issue
Block a user