public function column($name, $label = '')
    {
        $relationName = $relationColumn = '';

        if (false !== strpos($name, '.')) {
            list($relationName, $relationColumn) = explode('.', $name);

            $relation = $this->model()->eloquent()->$relationName();

            $label = empty($label) ? ucfirst($relationColumn) : $label;

            $name = snake_case($relationName).'.'.$relationColumn;
        }

        $column = $this->addColumn($name, $label);

        if (isset($relation) && $relation instanceof Relation) {
            $this->model()->with($relationName);
            $column->setRelation($relationName, $relationColumn);
        }

        return $column;
    }
public function column($name, $label = '')
    {
        $relationName = $relationColumn = '';

        if (false !== strpos($name, '.')) {
            list($relationName, $relationColumn) = explode('.', $name);

            $relation = $this->model()->eloquent()->$relationName();

            $label = empty($label) ? ucfirst($relationColumn) : $label;

            $name = snake_case($relationName).'.'.$relationColumn;
        }

        $column = $this->addColumn($name, $label);

        if (isset($relation) && $relation instanceof Relation) {
            $this->model()->with($relationName);
            $column->setRelation($relationName, $relationColumn);
        }

        return $column;
    }
public function column ( $ name , $ label = '' ) { $ relationName = $ relationColumn = '' ; if ( false !== strpos ( $ name , '.' ) ) { list ( $ relationName , $ relationColumn ) = explode ( '.' , $ name ) ; $ relation = $ this -> model ( ) -> eloquent ( ) -> $ relationName ( ) ; $ label = empty ( $ label ) ? ucfirst ( $ relationColumn ) : $ label ; $ name = snake_case ( $ relationName ) . '.' . $ relationColumn ; } $ column = $ this -> addColumn ( $ name , $ label ) ; if ( isset ( $ relation ) && $ relation instanceof Relation ) { $ this -> model ( ) -> with ( $ relationName ) ; $ column -> setRelation ( $ relationName , $ relationColumn ) ; } return $ column ; }
Add column to Grid.

@param string $name
@param string $label

@return Column
Add column to Grid .