protected function makeListColumn($name, $config)
    {
        if (is_string($config)) {
            $label = $config;
        }
        elseif (isset($config['label'])) {
            $label = $config['label'];
        }
        else {
            $label = studly_case($name);
        }

        /*
         * Auto configure pivot relation
         */
        if (starts_with($name, 'pivot[') && strpos($name, ']') !== false) {
            $_name = HtmlHelper::nameToArray($name);
            $relationName = array_shift($_name);
            $valueFrom = array_shift($_name);

            if (count($_name) > 0) {
                $valueFrom  .= '['.implode('][', $_name).']';
            }

            $config['relation'] = $relationName;
            $config['valueFrom'] = $valueFrom;
            $config['searchable'] = false;
        }
        /*
         * Auto configure standard relation
         */
        elseif (strpos($name, '[') !== false && strpos($name, ']') !== false) {
            $config['valueFrom'] = $name;
            $config['sortable'] = false;
            $config['searchable'] = false;
        }

        $columnType = $config['type'] ?? null;

        $column = new ListColumn($name, $label);
        $column->displayAs($columnType, $config);

        return $column;
    }
protected function makeListColumn($name, $config)
    {
        if (is_string($config)) {
            $label = $config;
        }
        elseif (isset($config['label'])) {
            $label = $config['label'];
        }
        else {
            $label = studly_case($name);
        }

        /*
         * Auto configure pivot relation
         */
        if (starts_with($name, 'pivot[') && strpos($name, ']') !== false) {
            $_name = HtmlHelper::nameToArray($name);
            $relationName = array_shift($_name);
            $valueFrom = array_shift($_name);

            if (count($_name) > 0) {
                $valueFrom  .= '['.implode('][', $_name).']';
            }

            $config['relation'] = $relationName;
            $config['valueFrom'] = $valueFrom;
            $config['searchable'] = false;
        }
        /*
         * Auto configure standard relation
         */
        elseif (strpos($name, '[') !== false && strpos($name, ']') !== false) {
            $config['valueFrom'] = $name;
            $config['sortable'] = false;
            $config['searchable'] = false;
        }

        $columnType = $config['type'] ?? null;

        $column = new ListColumn($name, $label);
        $column->displayAs($columnType, $config);

        return $column;
    }
protected function makeListColumn ( $ name , $ config ) { if ( is_string ( $ config ) ) { $ label = $ config ; } elseif ( isset ( $ config [ 'label' ] ) ) { $ label = $ config [ 'label' ] ; } else { $ label = studly_case ( $ name ) ; } /*
         * Auto configure pivot relation
         */ if ( starts_with ( $ name , 'pivot[' ) && strpos ( $ name , ']' ) !== false ) { $ _name = HtmlHelper :: nameToArray ( $ name ) ; $ relationName = array_shift ( $ _name ) ; $ valueFrom = array_shift ( $ _name ) ; if ( count ( $ _name ) > 0 ) { $ valueFrom .= '[' . implode ( '][' , $ _name ) . ']' ; } $ config [ 'relation' ] = $ relationName ; $ config [ 'valueFrom' ] = $ valueFrom ; $ config [ 'searchable' ] = false ; } /*
         * Auto configure standard relation
         */ elseif ( strpos ( $ name , '[' ) !== false && strpos ( $ name , ']' ) !== false ) { $ config [ 'valueFrom' ] = $ name ; $ config [ 'sortable' ] = false ; $ config [ 'searchable' ] = false ; } $ columnType = $ config [ 'type' ] ?? null ; $ column = new ListColumn ( $ name , $ label ) ; $ column -> displayAs ( $ columnType , $ config ) ; return $ column ; }
Creates a list column object from it's name and configuration.
Creates a list column object from it s name and configuration .