/**
  * Экшен для добавления комментария к заявке.
  */
 public function actionComment()
 {
     if (Yii::$app->getRequest()->post()) {
         $leadComments = new LeadComment();
         $leadComments->load(Yii::$app->getRequest()->post());
         /** @var \common\models\User $user */
         $user = Yii::$app->getUser()->getIdentity();
         /** @var \common\models\Lead $lead */
         $lead = Lead::findOne(['lead_id' => $leadComments->getLeadId(), 'company_id' => $user->getCompanyId(), 'is_deleted' => false]);
         if (!$lead) {
             throw new NotFoundHttpException('Заявка не найдена!');
         }
         $leadComments->save();
         $this->leadLogger->write($lead, LeadActionLog::ACTION_ADD_COMMENT, ['comment_id' => $leadComments->getCommentId()]);
         $this->redirect(['/lead/view', 'id' => $leadComments->getLeadId()]);
     }
 }
Exemple #2
0
 public function getComments()
 {
     return $this->hasMany(LeadComment::className(), ['lead_id' => 'lead_id'])->all();
 }