2020-06-26 23:32:33 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Notifications;
|
|
|
|
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
use App\Comment;
|
|
|
|
use App\Application;
|
2020-08-31 21:06:00 +00:00
|
|
|
use App\Traits\Cancellable;
|
|
|
|
use App\Facades\Options;
|
2020-06-26 23:32:33 +00:00
|
|
|
|
|
|
|
class NewComment extends Notification implements ShouldQueue
|
|
|
|
{
|
2020-08-31 21:06:00 +00:00
|
|
|
use Queueable, Cancellable;
|
2020-06-26 23:32:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
protected $application;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new notification instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct(Comment $comment, Application $application)
|
|
|
|
{
|
|
|
|
$this->application = $application;
|
|
|
|
}
|
|
|
|
|
2020-08-31 21:06:00 +00:00
|
|
|
public function optOut($notifiable)
|
2020-06-26 23:32:33 +00:00
|
|
|
{
|
2020-08-31 21:06:00 +00:00
|
|
|
return Options::getOption('notify_application_comment') !== 1;
|
2020-06-26 23:32:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the mail representation of the notification.
|
|
|
|
*
|
|
|
|
* @param mixed $notifiable
|
|
|
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
|
|
|
*/
|
|
|
|
public function toMail($notifiable)
|
|
|
|
{
|
|
|
|
return (new MailMessage)
|
|
|
|
->from(config('notification.sender.address'), config('notification.sender.name'))
|
|
|
|
->subject(config('app.name') . ' - New comment')
|
|
|
|
->line('Someone has just posted a new comment on an application you follow.')
|
|
|
|
->line('You\'re receiving this email because you\'ve voted/commented on this application.')
|
2020-07-16 20:21:28 +00:00
|
|
|
->action('Check it out', url(route('showUserApp', ['application' => $this->application->id])))
|
2020-06-26 23:32:33 +00:00
|
|
|
->line('Thank you!');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the array representation of the notification.
|
|
|
|
*
|
|
|
|
* @param mixed $notifiable
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function toArray($notifiable)
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
//
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|