public function getRelationData(Model $model)
    {
        $relations = $this->getRelations($model);
        if (empty($relations)) {
            return [];
        }
        $return = [];

        foreach ($this->properties as $name => $details) {
            try {
                $related = $model->{$name};
                if (!is_object($model->$name())) {
                    continue;
                }
            } catch (Exception $ex) {
                continue;
            }

            if (is_null($related)) {
                $related = $model->$name()->getModel();
                array_set($return, $name, [get_class($related) => $related->getFillable()]);
            }
            if (!is_null($related) && method_exists($related, 'getAttributes')) {
                array_set($return, $name, [get_class($related) => $related->getAttributes()]);
            }
        }
        return $return;
    }
public function getRelationData(Model $model)
    {
        $relations = $this->getRelations($model);
        if (empty($relations)) {
            return [];
        }
        $return = [];

        foreach ($this->properties as $name => $details) {
            try {
                $related = $model->{$name};
                if (!is_object($model->$name())) {
                    continue;
                }
            } catch (Exception $ex) {
                continue;
            }

            if (is_null($related)) {
                $related = $model->$name()->getModel();
                array_set($return, $name, [get_class($related) => $related->getFillable()]);
            }
            if (!is_null($related) && method_exists($related, 'getAttributes')) {
                array_set($return, $name, [get_class($related) => $related->getAttributes()]);
            }
        }
        return $return;
    }
public function getRelationData ( Model $ model ) { $ relations = $ this -> getRelations ( $ model ) ; if ( empty ( $ relations ) ) { return [ ] ; } $ return = [ ] ; foreach ( $ this -> properties as $ name => $ details ) { try { $ related = $ model -> { $ name } ; if ( ! is_object ( $ model -> $ name ( ) ) ) { continue ; } } catch ( Exception $ ex ) { continue ; } if ( is_null ( $ related ) ) { $ related = $ model -> $ name ( ) -> getModel ( ) ; array_set ( $ return , $ name , [ get_class ( $ related ) => $ related -> getFillable ( ) ] ) ; } if ( ! is_null ( $ related ) && method_exists ( $ related , 'getAttributes' ) ) { array_set ( $ return , $ name , [ get_class ( $ related ) => $ related -> getAttributes ( ) ] ) ; } } return $ return ; }
Gets prepared data from related model

@param Model $model
@return array
Gets prepared data from related model