public function loadRelationshipOptions(&$options)
    {
        //if we want all of the possible items on the other model, load them up, otherwise leave the options empty
        $items        = array();
        $model        = $this->config->getDataModel();
        $relationship = $model->{$options['field_name']}();
        $relatedModel = $relationship->getRelated();

        if ($this->validator->arrayGet($options, 'load_relationships')) {
            //if a sort field was supplied, order the results by it
            if ($optionsSortField = $this->validator->arrayGet($options, 'options_sort_field')) {
                $optionsSortDirection = $this->validator->arrayGet($options, 'options_sort_direction', $this->defaults['options_sort_direction']);

                $query = $relatedModel->orderBy($this->db->raw($optionsSortField), $optionsSortDirection);
            }
            //otherwise just pull back an unsorted list
            else {
                $query = $relatedModel->newQuery();
            }

            //run the options filter
            $options['options_filter']($query);

            //get the items
            $items = $query->get();
        }
        //otherwise if there are relationship items, we need them in the initial options list
        elseif ($relationshipItems = $relationship->get()) {
            $items = $relationshipItems;

            // if no related items exist, add default item, if set in options
            if (count($items) == 0 && array_key_exists('value', $options)) {
                $items = $relatedModel->where($relatedModel->getKeyName(), '=', $options['value'])->get();
            }
        }

        //map the options to the options property where array('id': [key], 'text': [nameField])
        $nameField          = $this->validator->arrayGet($options, 'name_field', $this->defaults['name_field']);
        $keyField           = $relatedModel->getKeyName();
        $options['options'] = $this->mapRelationshipOptions($items, $nameField, $keyField);
    }
public function loadRelationshipOptions(&$options)
    {
        //if we want all of the possible items on the other model, load them up, otherwise leave the options empty
        $items        = array();
        $model        = $this->config->getDataModel();
        $relationship = $model->{$options['field_name']}();
        $relatedModel = $relationship->getRelated();

        if ($this->validator->arrayGet($options, 'load_relationships')) {
            //if a sort field was supplied, order the results by it
            if ($optionsSortField = $this->validator->arrayGet($options, 'options_sort_field')) {
                $optionsSortDirection = $this->validator->arrayGet($options, 'options_sort_direction', $this->defaults['options_sort_direction']);

                $query = $relatedModel->orderBy($this->db->raw($optionsSortField), $optionsSortDirection);
            }
            //otherwise just pull back an unsorted list
            else {
                $query = $relatedModel->newQuery();
            }

            //run the options filter
            $options['options_filter']($query);

            //get the items
            $items = $query->get();
        }
        //otherwise if there are relationship items, we need them in the initial options list
        elseif ($relationshipItems = $relationship->get()) {
            $items = $relationshipItems;

            // if no related items exist, add default item, if set in options
            if (count($items) == 0 && array_key_exists('value', $options)) {
                $items = $relatedModel->where($relatedModel->getKeyName(), '=', $options['value'])->get();
            }
        }

        //map the options to the options property where array('id': [key], 'text': [nameField])
        $nameField          = $this->validator->arrayGet($options, 'name_field', $this->defaults['name_field']);
        $keyField           = $relatedModel->getKeyName();
        $options['options'] = $this->mapRelationshipOptions($items, $nameField, $keyField);
    }
public function loadRelationshipOptions ( & $ options ) { //if we want all of the possible items on the other model, load them up, otherwise leave the options empty $ items = array ( ) ; $ model = $ this -> config -> getDataModel ( ) ; $ relationship = $ model -> { $ options [ 'field_name' ] } ( ) ; $ relatedModel = $ relationship -> getRelated ( ) ; if ( $ this -> validator -> arrayGet ( $ options , 'load_relationships' ) ) { //if a sort field was supplied, order the results by it if ( $ optionsSortField = $ this -> validator -> arrayGet ( $ options , 'options_sort_field' ) ) { $ optionsSortDirection = $ this -> validator -> arrayGet ( $ options , 'options_sort_direction' , $ this -> defaults [ 'options_sort_direction' ] ) ; $ query = $ relatedModel -> orderBy ( $ this -> db -> raw ( $ optionsSortField ) , $ optionsSortDirection ) ; } //otherwise just pull back an unsorted list else { $ query = $ relatedModel -> newQuery ( ) ; } //run the options filter $ options [ 'options_filter' ] ( $ query ) ; //get the items $ items = $ query -> get ( ) ; } //otherwise if there are relationship items, we need them in the initial options list elseif ( $ relationshipItems = $ relationship -> get ( ) ) { $ items = $ relationshipItems ; // if no related items exist, add default item, if set in options if ( count ( $ items ) == 0 && array_key_exists ( 'value' , $ options ) ) { $ items = $ relatedModel -> where ( $ relatedModel -> getKeyName ( ) , '=' , $ options [ 'value' ] ) -> get ( ) ; } } //map the options to the options property where array('id': [key], 'text': [nameField]) $ nameField = $ this -> validator -> arrayGet ( $ options , 'name_field' , $ this -> defaults [ 'name_field' ] ) ; $ keyField = $ relatedModel -> getKeyName ( ) ; $ options [ 'options' ] = $ this -> mapRelationshipOptions ( $ items , $ nameField , $ keyField ) ; }
Loads the relationship options and sets the options option if load_relationships is true.

@param array $options
Loads the relationship options and sets the options option if load_relationships is true .