rules() public method

public rules ( ) : array
return array
Exemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return array_merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at', 'priority'], 'integer'], [['name', 'code'], 'required'], [['name'], 'string', 'max' => 255], [['code'], 'string', 'max' => 32], [['code'], 'unique'], ['code', 'default', 'value' => function ($model, $attribute) {
         return "sx_auto_" . md5(rand(1, 10) . time());
     }], ['priority', 'default', 'value' => function ($model, $attribute) {
         return 500;
     }]]);
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return ArrayHelper::merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at'], 'integer'], [['name'], 'required'], [['description'], 'string'], [['emails', 'phones', 'user_ids'], 'string'], [['name'], 'string', 'max' => 255], [['code'], 'string', 'max' => 32], [['code'], 'unique'], [['emails'], function ($attribute) {
         if ($this->emailsAsArray) {
             foreach ($this->emailsAsArray as $email) {
                 $validator = new EmailValidator();
                 if (!$validator->validate($email, $error)) {
                     $this->addError($attribute, $email . ' — ' . \Yii::t('skeeks/form2/app', 'Incorrect email address'));
                     return false;
                 }
             }
         }
     }]]);
 }
Exemplo n.º 3
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return ArrayHelper::merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at', 'result_count', 'pages'], 'integer'], [['data_server', 'data_session', 'data_cookie', 'data_request'], 'string'], [['phrase'], 'string', 'max' => 255], [['ip'], 'string', 'max' => 32], [['site_code'], 'string', 'max' => 15], ['data_request', 'default', 'value' => $_REQUEST], ['data_server', 'default', 'value' => $_SERVER], ['data_cookie', 'default', 'value' => $_COOKIE], ['data_session', 'default', 'value' => function (self $model, $attribute) {
         \Yii::$app->session->open();
         return $_SESSION;
     }], ['session_id', 'default', 'value' => function (self $model, $attribute) {
         \Yii::$app->session->open();
         return \Yii::$app->session->id;
     }], [['site_code'], 'default', 'value' => function (self $model, $attribute) {
         if (\Yii::$app->cms->site) {
             return \Yii::$app->cms->site->code;
         }
         return null;
     }], ['ip', 'default', 'value' => \skeeks\cms\helpers\Request::getRealUserIp()]]);
 }
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return array_merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at', 'property_id', 'element_id'], 'integer'], [['description'], 'string', 'max' => 255], [['value'], 'string'], ['value_enum', 'filter', 'filter' => function ($value) {
         $value = (int) $value;
         $filter_options = ['options' => ['default' => 0, 'min_range' => -2147483648.0, 'max_range' => 2147483647]];
         return filter_var($value, FILTER_VALIDATE_INT, $filter_options);
     }], ['value_enum', 'integer'], ['value_num', 'filter', 'filter' => function ($value) {
         $value = (double) $value;
         $min_range = -100000000000000.0;
         $max_range = 100000000000000.0;
         if ($value <= $min_range || $value >= $max_range) {
             return 0.0;
         }
         return $value;
     }], ['value_num', 'number']]);
 }
Exemplo n.º 5
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return array_merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at', 'size', 'image_height', 'image_width'], 'integer'], [['description_short', 'description_full'], 'string'], [['cluster_file', 'original_name', 'name'], 'string', 'max' => 255], [['cluster_id', 'mime_type', 'extension'], 'string', 'max' => 16], [['name_to_save'], 'string', 'max' => 32], [['cluster_id', 'cluster_file'], 'unique', 'targetAttribute' => ['cluster_id', 'cluster_file'], 'message' => Yii::t('skeeks/cms', 'The combination of Cluster ID and Cluster Src has already been taken.')]]);
 }
Exemplo n.º 6
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return array_merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at', 'property_id', 'element_id', 'value_enum'], 'integer'], [['value'], 'required'], [['value_num'], 'number'], [['description'], 'string', 'max' => 255], [['value'], 'string']]);
 }
Exemplo n.º 7
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return ArrayHelper::merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at', 'priority'], 'integer'], [['name'], 'required'], [['description', 'componentSettingsString'], 'string'], [['component_settings'], 'safe'], [['name', 'component'], 'string', 'max' => 255], [['active'], 'string', 'max' => 1], [['name'], 'unique'], [['personTypeIds'], 'safe'], [['priority'], 'default', 'value' => 100], [['active'], 'default', 'value' => Cms::BOOL_Y]]);
 }
Exemplo n.º 8
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return array_merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at', 'user_id', 'person_type_id', 'site_id'], 'integer'], [['additional'], 'string'], [['delivery_id'], 'integer'], [['user_id'], 'unique'], [['buyer_id'], 'integer'], [['pay_system_id'], 'integer'], [['pay_system_id', 'buyer_id', 'site_id', 'person_type_id', 'user_id'], 'required', 'on' => self::SCENARIO_CREATE_ORDER]]);
 }
Exemplo n.º 9
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return ArrayHelper::merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at', 'tax_id', 'person_type_id', 'priority'], 'integer'], [['tax_id', 'person_type_id'], 'required'], [['value'], 'number'], [['currency'], 'string', 'max' => 3], [['is_percent', 'is_in_price', 'active'], 'string', 'max' => 1], [['is_in_price'], 'default', 'value' => Cms::BOOL_N], [['is_percent', 'active'], 'default', 'value' => Cms::BOOL_Y], [['priority'], 'default', 'value' => 100], [['value'], 'default', 'value' => 0]]);
 }
Exemplo n.º 10
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return ArrayHelper::merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at', 'priority', 'multiple_cnt', 'version'], 'integer'], [['name', 'component'], 'required'], [['component_settings'], 'safe'], [['name', 'component', 'hint'], 'string', 'max' => 255], [['code'], function ($attribute) {
         if (!preg_match('/^[a-zA-Z]{1}[a-zA-Z0-9]{1,255}$/', $this->{$attribute})) {
             $this->addError($attribute, \Yii::t('skeeks/cms', 'Use only letters of the alphabet in lower or upper case and numbers, the first character of the letter (Example {code})', ['code' => 'code1']));
         }
     }], [['active', 'property_type', 'list_type', 'multiple', 'with_description', 'searchable', 'filtrable', 'is_required', 'smart_filtrable'], 'string', 'max' => 1], ['code', 'default', 'value' => function ($model, $attribute) {
         return "property" . StringHelper::ucfirst(md5(rand(1, 10) . time()));
     }], ['priority', 'default', 'value' => 500], [['active', 'searchable'], 'default', 'value' => Cms::BOOL_Y], [['is_required', 'smart_filtrable', 'filtrable', 'with_description'], 'default', 'value' => Cms::BOOL_N]]);
 }
Exemplo n.º 11
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return ArrayHelper::merge(parent::rules(), [[['priority'], 'integer'], [['code', 'name'], 'required'], [['description'], 'string'], [['code'], 'string', 'max' => 32], [['name'], 'string', 'max' => 255], [['xml_id'], 'string', 'max' => 255], [['def'], 'string', 'max' => 1], [['code'], 'unique']]);
 }
Exemplo n.º 12
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return array_merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at', 'priority', 'default_tree_id', 'root_tree_id'], 'integer'], [['name', 'content_type'], 'required'], [['description'], 'string'], [['meta_title_template'], 'string'], [['meta_description_template'], 'string'], [['meta_keywords_template'], 'string'], [['name', 'viewFile'], 'string', 'max' => 255], [['code'], 'string', 'max' => 50], [['code'], 'unique'], [['access_check_element'], 'string'], [['code'], 'validateCode'], [['active', 'index_for_search', 'tree_chooser', 'list_mode', 'is_allow_change_tree'], 'string', 'max' => 1], [['content_type'], 'string', 'max' => 32], [['name_meny', 'name_one'], 'string', 'max' => 100], ['priority', 'default', 'value' => 500], ['active', 'default', 'value' => Cms::BOOL_Y], ['is_allow_change_tree', 'default', 'value' => Cms::BOOL_Y], ['access_check_element', 'default', 'value' => Cms::BOOL_N], ['name_meny', 'default', 'value' => Yii::t('skeeks/cms', 'Elements')], ['name_one', 'default', 'value' => Yii::t('skeeks/cms', 'Element')], ['visible', 'default', 'value' => Cms::BOOL_Y], ['parent_content_is_required', 'default', 'value' => Cms::BOOL_Y], ['parent_content_on_delete', 'default', 'value' => self::CASCADE], ['parent_content_id', 'integer'], ['code', 'default', 'value' => function ($model, $attribute) {
         return "sxauto" . md5(rand(1, 10) . time());
     }]]);
 }
Exemplo n.º 13
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return array_merge(parent::rules(), [[['priority'], 'integer'], [['code', 'name'], 'required'], [['description'], 'string'], [['code'], 'string', 'max' => 2], [['name'], 'string', 'max' => 255], [['color'], 'string', 'max' => 32], [['code'], 'unique'], [['code'], 'validateCode']]);
 }
Exemplo n.º 14
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return ArrayHelper::merge(parent::rules(), [[['priority'], 'integer'], [['priority'], 'default', 'value' => 100], [['name'], 'required'], [['name'], 'string', 'max' => 255], [['active'], 'string', 'max' => 1], [['name'], 'unique'], [['siteCodes'], 'safe'], [['active'], 'default', 'value' => Cms::BOOL_Y], [['active'], 'validateActive']]);
 }
Exemplo n.º 15
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return array_merge(parent::rules(), [[['name'], 'required'], [['name'], 'unique'], [['name', 'description'], 'string']]);
 }
Exemplo n.º 16
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return array_merge(parent::rules(), [[['description_short', 'description_full'], 'string'], ['active', 'default', 'value' => Cms::BOOL_Y], [['redirect_code'], 'default', 'value' => 301], [['redirect_code'], 'in', 'range' => [301, 302]], [['redirect'], 'string'], [['name_hidden'], 'string'], [['priority', 'tree_type_id', 'image_id', 'image_full_id', 'redirect_tree_id', 'redirect_code'], 'integer'], [['tree_menu_ids'], 'safe'], [['code'], 'string', 'max' => 64], [['name'], 'string', 'max' => 255], [['meta_title', 'meta_description', 'meta_keywords'], 'string'], [['meta_title'], 'string', 'max' => 500], [['site_code'], 'string', 'max' => 15], [['pid', 'code'], 'unique', 'targetAttribute' => ['pid', 'code'], 'message' => \Yii::t('skeeks/cms', 'For this subsection of the code is already in use.')], [['pid', 'code'], 'unique', 'targetAttribute' => ['pid', 'code'], 'message' => \Yii::t('skeeks/cms', 'The combination of Code and Pid has already been taken.')], ['description_short_type', 'string'], ['description_full_type', 'string'], ['description_short_type', 'default', 'value' => "text"], ['description_full_type', 'default', 'value' => "text"], ['view_file', 'string', 'max' => 128]]);
 }
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ArrayHelper::merge(parent::rules(), ['id' => Yii::t('skeeks/shop/app', 'ID'), 'shop_product_id' => Yii::t('skeeks/shop/app', 'Shop Product ID'), 'quantity' => Yii::t('skeeks/shop/app', 'Available quantity'), 'quantity_reserved' => Yii::t('skeeks/shop/app', 'Reserved quantity'), 'measure_id' => Yii::t('skeeks/shop/app', 'Unit of measurement'), 'measure_ratio' => Yii::t('skeeks/shop/app', 'The coefficient unit')]);
 }
Exemplo n.º 18
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return array_merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at'], 'integer'], [['site_code', 'domain'], 'required'], [['site_code'], 'string', 'max' => 15], [['domain'], 'string', 'max' => 255], [['domain', 'site_code'], 'unique', 'targetAttribute' => ['domain', 'site_code'], 'message' => \Yii::t('app', 'The combination of Site Code and Domain has already been taken.')]]);
 }
Exemplo n.º 19
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return array_merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at', 'priority', 'multiple_cnt', 'version'], 'integer'], [['name', 'component'], 'required'], [['component_settings'], 'safe'], [['name', 'component', 'hint'], 'string', 'max' => 255], [['code'], 'string', 'max' => 64], [['active', 'property_type', 'list_type', 'multiple', 'with_description', 'searchable', 'filtrable', 'is_required', 'smart_filtrable'], 'string', 'max' => 1], ['code', 'default', 'value' => function ($model, $attribute) {
         return "property" . StringHelper::ucfirst(md5(rand(1, 10) . time()));
     }], ['priority', 'default', 'value' => 500], [['active', 'searchable'], 'default', 'value' => Cms::BOOL_Y], [['is_required', 'smart_filtrable', 'filtrable', 'with_description'], 'default', 'value' => Cms::BOOL_N]]);
 }
Exemplo n.º 20
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return array_merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at', 'priority'], 'integer'], [['code', 'name'], 'required'], [['active', 'def'], 'string', 'max' => 1], [['code'], 'string', 'max' => 15], [['name', 'server_name', 'description'], 'string', 'max' => 255], [['code'], 'unique'], [['code'], 'validateCode'], [['server_name'], 'validateServerName'], ['priority', 'default', 'value' => 500], ['active', 'default', 'value' => Cms::BOOL_Y], ['def', 'default', 'value' => Cms::BOOL_N], [['image_id'], 'integer']]);
 }
Exemplo n.º 21
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return array_merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at', 'user_id', 'person_type_id', 'site_id', 'store_id'], 'integer'], [['additional'], 'string'], [['delivery_id'], 'integer'], [['user_id'], 'unique'], [['buyer_id'], 'integer'], [['pay_system_id'], 'integer'], [['person_type_id'], 'default', 'value' => function (ShopFuser $model) {
         return $model->buyer && $model->buyer->shopPersonType ? $model->buyer->shopPersonType->id : null;
     }], [['pay_system_id', 'buyer_id', 'site_id', 'user_id'], 'required', 'on' => self::SCENARIO_CREATE_ORDER]]);
 }
Exemplo n.º 22
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return ArrayHelper::merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at'], 'integer'], [['name', 'code'], 'required'], [['description'], 'string'], [['name'], 'string', 'max' => 255], [['code'], 'string', 'max' => 50], [['site_code'], 'string', 'max' => 15]]);
 }
Exemplo n.º 23
0
 /**
  * @return array
  */
 public function rules()
 {
     return array_merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at', 'user_id'], 'integer'], [['value'], 'safe'], [['component'], 'string', 'max' => 255], [['site_code'], 'string', 'max' => 15], [['lang_code'], 'string', 'max' => 5], [['namespace'], 'string', 'max' => 50]]);
 }
Exemplo n.º 24
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return array_merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at', 'priority', 'default_children_tree_type'], 'integer'], [['name', 'code'], 'required'], [['description'], 'string'], [['name', 'viewFile'], 'string', 'max' => 255], [['code'], 'string', 'max' => 50], [['active', 'index_for_search'], 'string', 'max' => 1], [['name_meny', 'name_one'], 'string', 'max' => 100], [['code'], 'unique'], [['code'], 'validateCode'], ['priority', 'default', 'value' => 500], ['active', 'default', 'value' => "Y"], ['name_meny', 'default', 'value' => \Yii::t('skeeks/cms', 'Sections')], ['name_one', 'default', 'value' => \Yii::t('skeeks/cms', 'Section')]]);
 }
Exemplo n.º 25
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return ArrayHelper::merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at', 'priority'], 'integer'], [['name'], 'required'], [['rate'], 'number'], [['name'], 'string', 'max' => 255], [['active'], 'string', 'max' => 1], [['active'], 'default', 'value' => Cms::BOOL_Y], [['active'], 'in', 'range' => array_keys(\Yii::$app->cms->booleanFormat())]]);
 }
Exemplo n.º 26
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return array_merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at', 'priority', 'default_tree_id', 'root_tree_id'], 'integer'], [['name', 'content_type', 'code'], 'required'], [['description'], 'string'], [['meta_title_template'], 'string'], [['meta_description_template'], 'string'], [['meta_keywords_template'], 'string'], [['name', 'viewFile'], 'string', 'max' => 255], [['code'], 'string', 'max' => 50], [['code'], 'unique'], [['access_check_element'], 'string'], [['code'], 'validateCode'], [['active', 'index_for_search', 'tree_chooser', 'list_mode', 'is_allow_change_tree'], 'string', 'max' => 1], [['content_type'], 'string', 'max' => 32], [['name_meny', 'name_one'], 'string', 'max' => 100], ['priority', 'default', 'value' => 500], ['active', 'default', 'value' => Cms::BOOL_Y], ['is_allow_change_tree', 'default', 'value' => Cms::BOOL_Y], ['access_check_element', 'default', 'value' => Cms::BOOL_N], ['name_meny', 'default', 'value' => Yii::t('app', 'Elements')], ['name_one', 'default', 'value' => Yii::t('app', 'Element')]]);
 }
Exemplo n.º 27
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return ArrayHelper::merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at'], 'integer'], [['name', 'value'], 'required'], [['value'], 'number'], [['name'], 'string', 'max' => 50]]);
 }
Exemplo n.º 28
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return array_merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at', 'element_id', 'tree_id'], 'integer'], [['element_id', 'tree_id'], 'required'], [['element_id', 'tree_id'], 'unique', 'targetAttribute' => ['element_id', 'tree_id'], 'message' => \Yii::t('skeeks/cms', 'The combination of Element ID and Tree ID has already been taken.')]]);
 }
Exemplo n.º 29
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return ArrayHelper::merge(parent::rules(), [[['created_by', 'updated_by', 'created_at', 'updated_at', 'user_id'], 'integer'], [['comment', 'status_name'], 'string'], [['full_name', 'email'], 'string', 'max' => 255], [['phone'], 'string', 'max' => 50], [['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => \Yii::$app->user->identityClass, 'targetAttribute' => ['user_id' => 'id']], [['created_by'], 'exist', 'skipOnError' => true, 'targetClass' => \Yii::$app->user->identityClass, 'targetAttribute' => ['created_by' => 'id']], [['updated_by'], 'exist', 'skipOnError' => true, 'targetClass' => \Yii::$app->user->identityClass, 'targetAttribute' => ['updated_by' => 'id']], [['email'], 'email'], [['full_name'], 'default', 'value' => 'Покупатель'], [['products'], 'safe'], [['products'], 'required'], [['phone'], 'required'], [['phone'], PhoneValidator::className()]]);
 }