Granada\Granada::__get PHP Method

__get() public method

Added: check for get_{property_name} method defined in model and not null missing_{property_name} method is null or undefined in model fetched relationships not loaded relationship. "lazy load" if method exists
public __get ( $property )
    public function __get($property)
    {
        $result = $this->orm->get($property);
        if ($result !== null) {
            if (method_exists($this, $method = 'get_' . $property)) {
                return $this->{$method}($result);
            } else {
                return $result;
            }
        } elseif (method_exists($this, $method = 'missing_' . $property)) {
            return $this->{$method}();
        } elseif (array_key_exists($property, $this->relationships)) {
            return $this->relationships[$property];
        } elseif (method_exists($this, $property)) {
            if ($property != self::_get_id_column_name(get_class($this))) {
                $relation = $this->{$property}();
                return $this->relationships[$property] = in_array($this->relating, array('has_one', 'belongs_to')) ? $relation->find_one() : $relation->find_many();
            } else {
                return null;
            }
        } else {
            return null;
        }
    }