Skip to content
This repository has been archived by the owner on May 5, 2019. It is now read-only.

Commit

Permalink
update email notification
Browse files Browse the repository at this point in the history
  • Loading branch information
forehalo committed Jan 9, 2017
1 parent 47e7b21 commit 90f5e10
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
15 changes: 8 additions & 7 deletions app/Jobs/SendMailNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,21 @@ public function handle()
if (! env('APP_ENABLE_MAIL')) {
return;
}

if ($this->data->parent == 0) {
// parent comment
$parent = $this->data->parent;
if (is_null($parent)) {
$mail = Setting::get('email');
// Ensure receiver email configured.
if (!$mail) return;
$address = $mail;
$name = Setting::get('author');
} else {
$this->data->load('parent');
if (! $this->data->parent->subscription) return;
// Ensure parent comment subscript reply notification.
if (! $parent->subscription) return;

$address = $this->data->parent->email;
$name = $this->data->parent->name;
$address = $parent->email;
$name = $parent->name;
}
$this->data->load('post');

Mail::to($address, $name)->send(new ReplyNotification($this->data));
}
Expand Down
7 changes: 3 additions & 4 deletions app/Repositories/CommentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function getCommentsByPost($postID)
{
return Comment::where('post_id', $postID)
->with('parent')
->whereValid('true')
->whereValid(true)
->orderBy('created_at', 'desc')
->get();
}
Expand All @@ -39,9 +39,8 @@ public function create($postID, $inputs)
if ($comment->parent_id != 0) {
$comment->load('parent');
}

// add on comment_count
Post::where('id', $inputs['post_id'])->increment('comment_count');
$comment->load('post');
$comment->post->increment('comment_count');

return $comment;
}
Expand Down

0 comments on commit 90f5e10

Please sign in to comment.