public function actionSendToManager($idChat, $message) { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $model = new Messages(); $model->id_chat = $idChat; $model->from_user = Yii::$app->user->getId(); $model->to_user = \app\modules\user\models\UserClient::findOne(['user_id' => $model->from_user])->manager_id; $model->message = $message; if ($model->save()) { return ['status' => true]; } else { return ['status' => false]; } }
public function getClient() { return $this->hasOne(UserClient::className(), ['user_id' => 'user_id']); }