public function getNestedRelationships($name)
    {
        $pieces     = explode('.', $name);
        $models     = array();
        $num_pieces = sizeof($pieces);

        //iterate over the relationships to see if they're all valid
        foreach ($pieces as $i => $rel) {
            //if this is the first item, then the model is the config's model
            if ($i === 0) {
                $models[] = $this->config->getDataModel();
            }

            //if the model method doesn't exist for any of the pieces along the way, exit out
            if (!method_exists($models[$i], $rel) || !is_a($models[$i]->{$rel}(), self::BELONGS_TO)) {
                throw new \InvalidArgumentException("The '".$this->getOption('column_name')."' column in your ".$this->config->getOption('name').
                    " model configuration needs to be either a belongsTo relationship method name or a sequence of them connected with a '.'");
            }

            //we don't need the model of the last item
            $models[] = $models[$i]->{$rel}()->getRelated();
        }

        return array('models' => $models, 'pieces' => $pieces);
    }
public function getNestedRelationships($name)
    {
        $pieces     = explode('.', $name);
        $models     = array();
        $num_pieces = sizeof($pieces);

        //iterate over the relationships to see if they're all valid
        foreach ($pieces as $i => $rel) {
            //if this is the first item, then the model is the config's model
            if ($i === 0) {
                $models[] = $this->config->getDataModel();
            }

            //if the model method doesn't exist for any of the pieces along the way, exit out
            if (!method_exists($models[$i], $rel) || !is_a($models[$i]->{$rel}(), self::BELONGS_TO)) {
                throw new \InvalidArgumentException("The '".$this->getOption('column_name')."' column in your ".$this->config->getOption('name').
                    " model configuration needs to be either a belongsTo relationship method name or a sequence of them connected with a '.'");
            }

            //we don't need the model of the last item
            $models[] = $models[$i]->{$rel}()->getRelated();
        }

        return array('models' => $models, 'pieces' => $pieces);
    }
public function getNestedRelationships ( $ name ) { $ pieces = explode ( '.' , $ name ) ; $ models = array ( ) ; $ num_pieces = sizeof ( $ pieces ) ; //iterate over the relationships to see if they're all valid foreach ( $ pieces as $ i => $ rel ) { //if this is the first item, then the model is the config's model if ( $ i === 0 ) { $ models [ ] = $ this -> config -> getDataModel ( ) ; } //if the model method doesn't exist for any of the pieces along the way, exit out if ( ! method_exists ( $ models [ $ i ] , $ rel ) || ! is_a ( $ models [ $ i ] -> { $ rel } ( ) , self :: BELONGS_TO ) ) { throw new \ InvalidArgumentException ( "The '" . $ this -> getOption ( 'column_name' ) . "' column in your " . $ this -> config -> getOption ( 'name' ) . " model configuration needs to be either a belongsTo relationship method name or a sequence of them connected with a '.'" ) ; } //we don't need the model of the last item $ models [ ] = $ models [ $ i ] -> { $ rel } ( ) -> getRelated ( ) ; } return array ( 'models' => $ models , 'pieces' => $ pieces ) ; }
Converts the relationship key.

@param string $name //the relationship name

@return false|array('models' => array(), 'pieces' => array())
Converts the relationship key .