Exemplo n.º 1
0
 public function rules()
 {
     return [['name', 'required', 'when' => function ($model) {
         return $model->isNewRecord;
     }], ['name', 'match', 'pattern' => '#^[\\w_]+$#i', 'when' => function ($model) {
         return $model->isNewRecord;
     }], ['name', 'unique', 'targetClass' => Applications::className(), 'message' => Yii::t('backend', 'Такое приложение уже есть')], ['name', 'string', 'min' => 2, 'max' => 255, 'when' => function ($model) {
         return $model->isNewRecord;
     }], ['name', 'controllerFileExists', 'when' => function ($model) {
         return $model->isNewRecord;
     }], ['name', 'viewFolderExists', 'when' => function ($model) {
         return $model->isNewRecord;
     }], ['model_table_name', 'match', 'pattern' => '#^[\\w_}{\\%}]+$#i'], ['model_table_name', 'tableExists', 'when' => function ($model) {
         return $model->isNewRecord;
     }], ['model_table_name', 'modelFileExists', 'when' => function ($model) {
         return $model->isNewRecord;
     }], ['example', 'exampleExists', 'when' => function ($model) {
         return $model->isNewRecord;
     }], [['filters', 'itemsSearch', 'itemsSort', 'defaultOrderDesc', 'itemsColumns', 'defaultPageSize'], 'integer'], ['simpleItemLinks', 'integer'], ['title', 'required'], ['title', 'string', 'max' => 255], ['app_alias', 'validateAppAlias'], [['content', 'intro', 'metaDescription', 'metaKeywords'], 'string'], [['metaTitle', 'defaultOrder'], 'string', 'max' => 255]];
 }
Exemplo n.º 2
0
 public function getApp()
 {
     return $this->hasOne(Applications::className(), ['id' => 'app_id']);
 }