public function isDisabled() { // if (Yii::$app->user->username !== 'admin') { // return true; // } return parent::isDisabled(); }
/** * Override isDisabled method if you need as shown in the * example below. You can override similarly other methods * like isActive, isMovable etc. */ public function isDisabled() { if (!Yii::$app->user->can('admin')) { return true; } return parent::isDisabled(); }
/** * @inheritdoc */ public function beforeSave($insert) { if (parent::beforeSave($insert)) { $this->id_student = Yii::$app->session['id_student']; $this->collapsed = 1; return true; } else { return false; } }
public function attributeLabels() { $attributeLabels = parent::attributeLabels(); return $attributeLabels + ['alias' => Yii::t('app', 'Alias'), 'created' => Yii::t('app', 'Created'), 'updated' => Yii::t('app', 'Updated'), 'owner' => Yii::t('app', 'Owner'), 'editor' => Yii::t('app', 'Editor'), 'h1' => Yii::t('app', 'H1'), 'title' => Yii::t('app', 'Title'), 'keywords' => Yii::t('app', 'Keywords'), 'description' => Yii::t('app', 'Keywords')]; }
/** * Validation of source query data * * @throws InvalidConfigException */ protected function validateSourceData() { if (empty($this->query) || !$this->query instanceof ActiveQuery) { throw new InvalidConfigException("The 'query' property must be defined and must be an instance of '" . ActiveQuery::className() . "'."); } $class = isset($this->query->modelClass) ? $this->query->modelClass : null; if (empty($class) || !is_subclass_of($class, ActiveRecord::className())) { throw new InvalidConfigException("The 'query' must be implemented using 'ActiveRecord::find()' method."); } $trait = 'kartik\\tree\\models\\TreeTrait'; if (!self::usesTrait($class, $trait)) { throw new InvalidConfigException("The model class '{$class}' for the 'query' must use the trait '{$trait}' or extend from '" . Tree::className() . "''."); } }
public function afterDelete() { self::buildCache(); parent::afterDelete(); }
/** * Override isDisabled method if you need as shown in the * example below. You can override similarly other methods * like isActive, isMovable etc. * * @return bool */ public function isDisabled() { return parent::isDisabled(); }
/** * @return array */ public function behaviors() { return array_merge(parent::behaviors(), [['class' => SluggableBehavior::className(), 'attribute' => 'name', 'ensureUnique' => true], ['class' => TimestampBehavior::className()], ['class' => ImageAttachmentBehavior::className()]]); }
public function rules() { $rules = parent::rules(); $rules[] = [['description'], 'string']; return $rules; }
/** * @inheritdoc * (array) rules : * @return array */ public function rules() { $rules = parent::rules(); $rules[] = [['route', 'target', 'title'], 'safe']; return $rules; }
/** * @inheritdoc * (array) rules : * @return array */ public function rules() { $rules = parent::rules(); $rules[] = [['codes', 'name1', 'classmark'], 'safe']; return $rules; }
/** * Override isDisabled method if you need as shown in the * example below. You can override similarly other methods * like isActive, isMovable etc. public function isDisabled() { if (Yii::$app->user->id !== '1') { return true; } return parent::isDisabled(); } */ public function rules() { $rules = parent::rules(); $rules[] = ['description', 'safe']; return $rules; }