public function getModelRelatedItems($model, Field $field)
    {
        $name = $field->getOption('field_name');

        if ($field->getOption('multiple_values')) {
            //if a sort_field is provided, use it, otherwise sort by the name field
            if ($sortField = $field->getOption('sort_field')) {
                return $model->{$name}()->orderBy($sortField)->get();
            } else {
                return $model->{$name}()->get();
            }
        } else {
            return $model->{$name}()->get();
        }
    }
public function getModelRelatedItems($model, Field $field)
    {
        $name = $field->getOption('field_name');

        if ($field->getOption('multiple_values')) {
            //if a sort_field is provided, use it, otherwise sort by the name field
            if ($sortField = $field->getOption('sort_field')) {
                return $model->{$name}()->orderBy($sortField)->get();
            } else {
                return $model->{$name}()->get();
            }
        } else {
            return $model->{$name}()->get();
        }
    }
public function getModelRelatedItems ( $ model , Field $ field ) { $ name = $ field -> getOption ( 'field_name' ) ; if ( $ field -> getOption ( 'multiple_values' ) ) { //if a sort_field is provided, use it, otherwise sort by the name field if ( $ sortField = $ field -> getOption ( 'sort_field' ) ) { return $ model -> { $ name } ( ) -> orderBy ( $ sortField ) -> get ( ) ; } else { return $ model -> { $ name } ( ) -> get ( ) ; } } else { return $ model -> { $ name } ( ) -> get ( ) ; } }
Fills a model with the necessary relationship values.

@param \Illuminate\Database\Eloquent\Model    $model
@param \Frozennode\Administrator\Fields\Field $field

@return \Illuminate\Database\Eloquent\Collection
Fills a model with the necessary relationship values .