true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'user_id' => 'Пользователь', ]; } public function beforeDelete() { foreach ($this->managerEmployees as $employee){ $employee->delete(); } return parent::beforeDelete(); } /** * @return ActiveQuery */ public function getUser() { return $this->hasOne(User::className(), ['id' => 'user_id']); } /** * @return ActiveQuery */ public function getManagerEmployees() { return $this->hasMany(ManagerEmployee::className(), ['manager_id' => 'id']); } }