Fixing a few things in Eloquent 2.
This commit is contained in:
@@ -547,6 +547,34 @@ abstract class Model {
|
||||
$this->{"set_{$key}"}($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if an attribute exists on the model.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($key)
|
||||
{
|
||||
foreach (array('attributes', 'relationships') as $source)
|
||||
{
|
||||
if (array_key_exists($key, $this->$source)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an attribute from the model.
|
||||
*
|
||||
* @param string $key
|
||||
* @return void
|
||||
*/
|
||||
public function __unset($key)
|
||||
{
|
||||
foreach (array('attributes', 'relationships') as $source)
|
||||
{
|
||||
unset($this->$source[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle dynamic method calls on the model.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user