self::SCENARIO_CREATE], [['user_id'], 'integer'], [['created_at'], 'safe'], [['folder_path', 'secret'], 'string', 'max' => 255], [['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::class, 'targetAttribute' => ['user_id' => 'id']], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => '收集任务id', 'user_id' => '用户id', 'folder_path' => '收集目标文件夹(相对路径)', 'created_at' => '任务创建时间', 'secret' => '访问密钥', ]; } /** * {@inheritdoc} */ public function scenarios() { $scenarios = parent::scenarios(); $scenarios[self::SCENARIO_CREATE] = ['folder_path', 'secret']; // 在这里列出你想在创建收集任务时验证的属性 return $scenarios; } /** * Gets query for [[CollectionUploadeds]]. * * @return ActiveQuery */ public function getCollectionUploadeds() { return $this->hasMany(CollectionUploaded::class, ['task_id' => 'id']); } /** * Gets query for [[User]]. * * @return ActiveQuery */ public function getUser() { return $this->hasOne(User::class, ['id' => 'user_id']); } }