rearrange __get hierarchy so eloquent models can have methods that have the same name as columns.
This commit is contained in:
@@ -424,9 +424,13 @@ abstract class Model {
|
|||||||
*/
|
*/
|
||||||
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 @@ abstract class Model {
|
|||||||
|
|
||||||
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];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user