use App\Comment;
use App\User;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class MentionedUser extends Notification
{
public function __construct(Comment $comment, User $user)
{
$this->comment = $comment;
$this->user = $user;
}
public function via($notifiable)
{
return ['mail', 'database'];
}
public function toMail($notifiable)
{
$message = (new MailMessage())
->subject('['.$this->comment->discussion->group->name.'] '.trans('messages.you_have_been_mentionned_by').' '.$this->user->name)
->line(trans('messages.you_have_been_mentionned_by').' '.$this->user->name.' '.trans('messages.in_the_discussion').' '.$this->comment->discussion->name.' : ')
->line(html_entity_decode(strip_tags(filter($this->comment->body))))
->action(trans('messages.reply'), route('groups.discussions.show', [$this->comment->discussion->group, $this->comment->discussion]))
->line(trans('messages.dont_reply_to_this_email'));
if ($this->comment->discussion->inbox()) {
$message->from($this->comment->discussion->inbox(), $this->comment->discussion->group->name);
}
else {
$message->from(config('mail.noreply'), config('mail.from.name'));
}
return $message;
}
}