src/grid/ClientColumn.php
public function init()
    {
        parent::init();

        $this->visible = Yii::$app->user->can('access-subclients');
        if (!$this->visible) {
            return null;
        }

        if (!$this->sortAttribute) {
            $this->sortAttribute = $this->nameAttribute;
        }
        if ($this->value === null) {
            $this->value = function ($model) {
                if (Yii::$app->user->identity->hasSeller($model->{$this->idAttribute})) {
                    return $model->{$this->nameAttribute};
                } else {
                    return Html::a($model->{$this->nameAttribute}, ['@client/view', 'id' => $model->{$this->idAttribute}]);
                }
            };
        }
        if (!empty($this->grid->filterModel)) {
            if (!isset($this->filterInputOptions['id'])) {
                $this->filterInputOptions['id'] = $this->attribute;
            }
            if ($this->filter === null && strpos($this->attribute, '_like') === false) {
                $this->filter = $this->getDefaultFilter();
            }
        }

        return true;
    }
public function init()
    {
        parent::init();

        $this->visible = Yii::$app->user->can('access-subclients');
        if (!$this->visible) {
            return null;
        }

        if (!$this->sortAttribute) {
            $this->sortAttribute = $this->nameAttribute;
        }
        if ($this->value === null) {
            $this->value = function ($model) {
                if (Yii::$app->user->identity->hasSeller($model->{$this->idAttribute})) {
                    return $model->{$this->nameAttribute};
                } else {
                    return Html::a($model->{$this->nameAttribute}, ['@client/view', 'id' => $model->{$this->idAttribute}]);
                }
            };
        }
        if (!empty($this->grid->filterModel)) {
            if (!isset($this->filterInputOptions['id'])) {
                $this->filterInputOptions['id'] = $this->attribute;
            }
            if ($this->filter === null && strpos($this->attribute, '_like') === false) {
                $this->filter = $this->getDefaultFilter();
            }
        }

        return true;
    }
public function init ( ) { parent :: init ( ) ; $ this -> visible = Yii :: $ app -> user -> can ( 'access-subclients' ) ; if ( ! $ this -> visible ) { return null ; } if ( ! $ this -> sortAttribute ) { $ this -> sortAttribute = $ this -> nameAttribute ; } if ( $ this -> value === null ) { $ this -> value = function ( $ model ) { if ( Yii :: $ app -> user -> identity -> hasSeller ( $ model -> { $ this -> idAttribute } ) ) { return $ model -> { $ this -> nameAttribute } ; } else { return Html :: a ( $ model -> { $ this -> nameAttribute } , [ '@client/view' , 'id' => $ model -> { $ this -> idAttribute } ] ) ; } } ; } if ( ! empty ( $ this -> grid -> filterModel ) ) { if ( ! isset ( $ this -> filterInputOptions [ 'id' ] ) ) { $ this -> filterInputOptions [ 'id' ] = $ this -> attribute ; } if ( $ this -> filter === null && strpos ( $ this -> attribute , '_like' ) === false ) { $ this -> filter = $ this -> getDefaultFilter ( ) ; } } return true ; }
Sets visibility and default behaviour for value and filter when visible.
Sets visibility and default behaviour for value and filter when visible .