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