Closed JackS9 closed 11 months ago
Just a note that this functionality already exists on the Relational
class in the form of the hasAttribute()
method. Adding an __isset
magic method isn't a bad idea, though, but should probably just return the other method (or vice-versa).
/**
* Check if attributes (i.e. field) on the model is set
*
* @param string $name The key to check if set
* @return boolean
*/
public function __isset($name)
{
return $this->hasAttribute($name);
}
I changed to what Shawn suggested; however, I noticed that __get() could also use hasAttribute()
// Next check for an attribute on the model
if (isset($this->attributes[$name]))
{
return $this->attributes[$name];
}
This is an alternate solution to PR 1661