/**
  * Get comment.
  * 
  * @param  mixed $data
  * @return array|null
  */
 private function extractComment($data)
 {
     if (is_numeric($data) && ($comment = Comment::find($data))) {
         return compact('comment');
     }
     return null;
 }
 /**
  * @param  Comment $comment
  * @return void
  */
 public function onCommentCreated(Comment $comment)
 {
     if (!$comment->parent) {
         return false;
     }
     $to = $comment->parent->present()->authorEmail;
     if ($to === $comment->present()->authorEmail) {
         return false;
     }
     if ($comment->parent->user) {
         $comment->parent->user->notifications()->save(new Notification(['type' => Notification::TYPE_COMMENT, 'data' => $comment->id]));
         if (!$comment->parent->user->hasNotification('comment')) {
             return false;
         }
     }
     $this->mailer->sendCommentReply($to, $comment);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $comment = Comment::findOrFail($id);
     $input = Input::only('content', 'status');
     if (in_array($input['status'], ['approved', 'unapproved', 'trash'])) {
         $comment->status = $input['status'];
     }
     if (!empty($input['content'])) {
         $comment->content = Comments::parse($input['content']);
     }
     $comment->save();
     return json(1);
 }
Esempio n. 4
0
 /**
  * Send comment reply.
  * 
  * @param  mixed  				   $to
  * @param  \FIIP\Comments\Comment  $data
  * @return void
  */
 public function sendCommentReply($to, Comment $comment)
 {
     $data = ['author' => $comment->present()->authorName, 'content' => $comment->content, 'url' => $comment->present()->url];
     $subject = 'Ai primit un răspuns de la ' . $data['author'];
     $this->sendTo($to, $subject, 'emails.comment-reply', $data);
 }