Commit c4ece2d5 authored by Taylor Otwell's avatar Taylor Otwell

rearrange __get hierarchy so eloquent models can have methods that have the same name as columns.

parent 695420c1
......@@ -424,9 +424,13 @@ abstract class Model {
*/
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?
// 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];
}
......@@ -438,10 +442,6 @@ abstract class Model {
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];
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment