rearrange __get hierarchy so eloquent models can have methods that have the same name as columns.
This commit is contained in:
parent
695420c127
commit
c4ece2d51f
|
@ -424,9 +424,13 @@ public function delete($id = null)
|
||||||
*/
|
*/
|
||||||
public function __get($key)
|
public function __get($key)
|
||||||
{
|
{
|
||||||
|
if (array_key_exists($key, $this->attributes))
|
||||||
|
{
|
||||||
|
return $this->attributes[$key];
|
||||||
|
}
|
||||||
// Is the requested item a model relationship that has already been loaded?
|
// Is the requested item a model relationship that has already been loaded?
|
||||||
// All of the loaded relationships are stored in the "ignore" array.
|
// All of the loaded relationships are stored in the "ignore" array.
|
||||||
if (array_key_exists($key, $this->ignore))
|
elseif (array_key_exists($key, $this->ignore))
|
||||||
{
|
{
|
||||||
return $this->ignore[$key];
|
return $this->ignore[$key];
|
||||||
}
|
}
|
||||||
|
@ -438,10 +442,6 @@ public function __get($key)
|
||||||
|
|
||||||
return $this->ignore[$key] = (in_array($this->relating, array('has_one', 'belongs_to'))) ? $query->first() : $query->get();
|
return $this->ignore[$key] = (in_array($this->relating, array('has_one', 'belongs_to'))) ? $query->first() : $query->get();
|
||||||
}
|
}
|
||||||
elseif (array_key_exists($key, $this->attributes))
|
|
||||||
{
|
|
||||||
return $this->attributes[$key];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue