public function rules() { return [[['periodInput', 'items', 'operatorId'], 'required'], ['periodInput', 'filter', 'filter' => function ($value) { $period = explode(self::PERIOD_DELIMITER, $value); $this->_period = ['month' => $period[0], 'year' => $period[1]]; return $value; }], ['operatorId', MongoIdValidator::className(), 'forceFormat' => 'object'], ['operatorId', 'exist', 'targetClass' => Operator::className(), 'targetAttribute' => '_id'], ['items', 'filter', 'filter' => function ($value) { foreach ($value as $item) { if (is_numeric($item)) { $this->_numbers[] = $item; } else { $this->_employees[] = $item; } $res[$item] = $item; } return $value; }]]; }
public function getOperator() { return $this->hasOne(Operator::className(), ['_id' => 'operatorId']); }