当前位置: 首页>>代码示例>>PHP>>正文


PHP ActiveRecord::rules方法代码示例

本文整理汇总了PHP中yii\db\ActiveRecord::rules方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::rules方法的具体用法?PHP ActiveRecord::rules怎么用?PHP ActiveRecord::rules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\db\ActiveRecord的用法示例。


在下文中一共展示了ActiveRecord::rules方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * @param array $params
  * @throws \yii\base\InvalidParamException
  */
 public function __construct($params)
 {
     $this->scenario = 'search';
     parent::__construct($params);
     if ($this->model === null) {
         throw new InvalidParamException('Param "model" cannot be empty');
     }
     $this->rules = $this->model->rules();
     $this->scenarios = $this->model->scenarios();
     foreach ($this->safeAttributes() as $attribute) {
         $this->attributes[$attribute] = '';
     }
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:17,代码来源:SearchModel.php

示例2: rules

 /**
  * @return array Validation rules
  */
 public function rules()
 {
     $items = parent::rules();
     if ($this->hasAttribute('created_at')) {
         $items[] = ['created_at', 'safe'];
     }
     if ($this->hasAttribute('updated_at')) {
         $items[] = ['updated_at', 'safe'];
     }
     return $items;
 }
开发者ID:platx,项目名称:yii2-active-record,代码行数:14,代码来源:ActiveRecord.php

示例3: rules

 /**
  * Make safe validation rules for behavior relations
  * @return array
  */
 public function rules()
 {
     $fields = [];
     foreach ($this->behaviors as $behavior) {
         if ($behavior instanceof HasRelation) {
             $fields[] = $behavior->getAttributeName();
             if ($behavior instanceof HasOneRelation) {
                 $fields[] = $behavior->selfField;
             }
         }
     }
     return array_merge(parent::rules(), [[$fields, 'safe']]);
 }
开发者ID:NullRefExcep,项目名称:yii2-core,代码行数:17,代码来源:Model.php

示例4: rules

 /**
  * @inheritdoc
  */
 public function rules()
 {
     $rules = parent::rules();
     $options = [];
     for ($i = 1; $i <= Message::OPTIONS_COUNT; $i++) {
         $options[] = 'option_' . $i;
     }
     $rules[] = [['created_user_id', 'created_user_name', 'created_ip'], 'required'];
     $rules[] = [array_merge(['content'], $options), 'string'];
     $rules[] = [['status', 'created_user_id', 'updated_user_id', 'for_document_id', 'for_user_id', 'parent_message_id'], 'integer'];
     $rules[] = [['title', 'attachment', 'created_user_name', 'updated_user_name'], 'string', 'max' => 255];
     $rules[] = [['created_ip'], 'string', 'max' => 19];
     $rules[] = [['content', 'title'], 'filter', 'filter' => 'trim'];
     $rules[] = [['status'], 'default', 'value' => self::STATUS_ACTIVE];
     $rules[] = [array_merge(['title', 'content', 'attachment', 'updated_at', 'updated_user_id', 'updated_user_name', 'for_document_id', 'for_user_id', 'parent_message_id'], $options), 'default', 'value' => null];
     $rules[] = [['created_at', 'updated_at'], 'safe'];
     return $rules;
 }
开发者ID:darkffh,项目名称:yii2-lowbase,代码行数:21,代码来源:Message.php

示例5: rules

 /**
  * @inheritdoc
  */
 public function rules()
 {
     $rules = parent::rules();
     $rules[] = [['name'], 'required'];
     $rules[] = [['name'], 'unique'];
     $options_name = [];
     $options_type = [];
     $options_param = [];
     $options_require = [];
     for ($i = 1; $i <= self::OPTIONS_COUNT; $i++) {
         $options_name[] = 'option_' . $i . '_name';
         $options_type[] = 'option_' . $i . '_type';
         $options_param[] = 'option_' . $i . '_param';
         $options_require[] = 'option_' . $i . '_require';
     }
     $rules[] = [array_merge(['name', 'path'], $options_name, $options_param), 'string', 'max' => 255];
     $rules[] = [array_merge($options_type, $options_require), 'integer'];
     $rules[] = [array_merge($options_name, ['name']), 'filter', 'filter' => 'trim'];
     $rules[] = [$options_require, 'default', 'value' => 0];
     $rules[] = [array_merge($options_type, $options_name, $options_param), 'default', 'value' => null];
     return $rules;
 }
开发者ID:darkffh,项目名称:yii2-lowbase,代码行数:25,代码来源:Template.php

示例6: rules

 public function rules()
 {
     $rules = parent::rules();
     $rules[] = [['changeTenant'], 'safe'];
     return $rules;
 }
开发者ID:antonio74,项目名称:daduu42,代码行数:6,代码来源:TenantActiveRecord.php

示例7: rules

 /**
  * @inheritdoc
  */
 public function rules()
 {
     return array_merge(parent::rules(), [['status', 'in', 'range' => [self::STATUS_ACTIVE, self::STATUS_DELETED]], ['status', 'default', 'value' => self::STATUS_ACTIVE]]);
 }
开发者ID:WondersLabCorporation,项目名称:yii2,代码行数:7,代码来源:ActiveRecord.php

示例8: rules

 /**
  * @inheritdoc
  */
 public function rules()
 {
     $rules = parent::rules();
     $options = [];
     for ($i = 1; $i <= Template::OPTIONS_COUNT; $i++) {
         $options[] = 'option_' . $i;
     }
     $rules[] = [['created_at', 'created_user_id', 'created_user_name', 'alias', 'name', 'parent_id', 'root_id', 'template_id', 'status'], 'required'];
     $rules[] = [['created_user_id', 'updated_user_id', 'template_id', 'parent_id', 'root_id', 'is_folder', 'status', 'last_parent_id', 'last_template_id'], 'integer'];
     $rules[] = ['alias', 'unique'];
     $rules[] = [array_merge(['annotation', 'content', 'meta_description', 'meta_keywords'], $options), 'string'];
     $rules[] = [['name', 'title', 'alias', 'img', 'created_user_name', 'updated_user_name', 'root_name', 'parent_name'], 'string', 'max' => 255];
     $rules[] = ['status', 'in', 'range' => array_keys(self::getStatuses())];
     $rules[] = [['name', 'title', 'alias'], 'filter', 'filter' => 'trim'];
     $rules[] = [array_merge(['title', 'annotation', 'meta_description', 'meta_keywords', 'content', 'img', 'updated_at', 'updated_user_id', 'updated_user_name', 'parent_name', 'root_name'], $options), 'default', 'value' => null];
     $rules[] = [['status'], 'default', 'value' => self::STATUS_ACTIVE];
     $rules[] = [['parent_id'], 'default', 'value' => 1];
     $rules[] = [['is_folder'], 'default', 'value' => 0];
     $rules[] = [['created_at', 'updated_at', 'fields'], 'safe'];
     return $rules;
 }
开发者ID:p0vidl0,项目名称:yii2-lowbase,代码行数:24,代码来源:Document.php

示例9: rules

 /**
  * @inheritDoc
  */
 public function rules()
 {
     return ArrayHelper::merge(parent::rules(), [[['title'], RequiredValidator::class]]);
 }
开发者ID:nanodesu88,项目名称:yii2-activerecord-attributes,代码行数:7,代码来源:AttributeEnumRecord.php

示例10: getRules

 public function getRules()
 {
     return $this->activeRecord->rules();
 }
开发者ID:jiangrongyong,项目名称:docgen,代码行数:4,代码来源:Model.php

示例11: rules

 /**
  * @inheritdoc
  */
 public function rules()
 {
     return array_merge(parent::rules(), [[['code'], 'required'], [['code'], 'unique'], [['code'], 'validateCode'], [['priority'], 'integer'], [['active'], 'string'], [['course'], 'number'], [['name', 'name_full'], 'safe']]);
 }
开发者ID:skeeks-cms,项目名称:cms-module-money,代码行数:7,代码来源:MoneyCurrency.php


注:本文中的yii\db\ActiveRecord::rules方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。