'Уже является менеджером'], [['user_card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['user_card_id' => 'id']], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'user_card_id' => 'Карточка менеджера', ]; } /** * @throws StaleObjectException * @throws \Throwable */ public function beforeDelete() { foreach ($this->managerEmployees as $employee){ $employee->delete(); } return parent::beforeDelete(); } /** * @return ActiveQuery */ public function getUserCard() { return $this->hasOne(UserCard::className(), ['id' => 'user_card_id']); } /** * @return ActiveQuery */ public function getManagerEmployees() { return $this->hasMany(ManagerEmployee::className(), ['manager_id' => 'id']); } }