public function resolveRelationship($alias, $data)
    {
        if (! in_array($alias, $this->relations) && ! method_exists($this, $alias)) {
            throw new BadMethodCallException("Relationship for field '" . $alias . "' not configured in " . get_class($this));
        }

        if (method_exists($this, $alias)) {
            // Use relationship *method* (prevail)
            $related = $this->$alias($data);
            return $related;
        }

        // try to craft relationship with simple snake_case to camelCase
        $relation = "\\NEM\\Models\\" . Str::studly($alias);

        if (! class_exists($relation)) {
            throw new BadMethodCallException("Relationship method for field '" . $alias . "' not implemented in " . get_class($this));
        }

        $related  = new $relation($data);
        return $related;
    }
public function resolveRelationship($alias, $data)
    {
        if (! in_array($alias, $this->relations) && ! method_exists($this, $alias)) {
            throw new BadMethodCallException("Relationship for field '" . $alias . "' not configured in " . get_class($this));
        }

        if (method_exists($this, $alias)) {
            // Use relationship *method* (prevail)
            $related = $this->$alias($data);
            return $related;
        }

        // try to craft relationship with simple snake_case to camelCase
        $relation = "\\NEM\\Models\\" . Str::studly($alias);

        if (! class_exists($relation)) {
            throw new BadMethodCallException("Relationship method for field '" . $alias . "' not implemented in " . get_class($this));
        }

        $related  = new $relation($data);
        return $related;
    }
public function resolveRelationship ( $ alias , $ data ) { if ( ! in_array ( $ alias , $ this -> relations ) && ! method_exists ( $ this , $ alias ) ) { throw new BadMethodCallException ( "Relationship for field '" . $ alias . "' not configured in " . get_class ( $ this ) ) ; } if ( method_exists ( $ this , $ alias ) ) { // Use relationship *method* (prevail) $ related = $ this -> $ alias ( $ data ) ; return $ related ; } // try to craft relationship with simple snake_case to camelCase $ relation = "\\NEM\\Models\\" . Str :: studly ( $ alias ) ; if ( ! class_exists ( $ relation ) ) { throw new BadMethodCallException ( "Relationship method for field '" . $ alias . "' not implemented in " . get_class ( $ this ) ) ; } $ related = new $ relation ( $ data ) ; return $ related ; }
Build a Model Relationship between \NEM\Contracts\DataTransferObject objects.

Relation can be defined with the `$relations` property on extending classes.

Relationships for which there is no method implementation, will automatically
try to instantiate using the uppercased CamelCase representation of the relation
alias.

@param   string  $alias      Relation alias name.
@param   array   $data       The relationship data.
@return  DataTransferObject|ModelCollection
Build a Model Relationship between \ NEM \ Contracts \ DataTransferObject objects .