2019-11-20 23:16:01 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Notifications\Messages;
|
|
|
|
|
2020-09-04 00:50:42 +08:00
|
|
|
use App\Contracts\Notification;
|
2019-11-20 23:16:01 +08:00
|
|
|
use App\Models\News;
|
|
|
|
use App\Notifications\Channels\MailChannel;
|
2021-05-20 23:54:07 +08:00
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
2019-11-20 23:16:01 +08:00
|
|
|
|
2021-05-20 23:54:07 +08:00
|
|
|
class NewsAdded extends Notification implements ShouldQueue
|
2019-11-20 23:16:01 +08:00
|
|
|
{
|
2021-05-20 23:54:07 +08:00
|
|
|
use Queueable;
|
2019-11-20 23:16:01 +08:00
|
|
|
use MailChannel;
|
|
|
|
|
2020-05-09 23:31:25 +08:00
|
|
|
public $channels = ['mail'];
|
2020-09-04 00:50:42 +08:00
|
|
|
public $requires_opt_in = true;
|
2020-05-09 23:31:25 +08:00
|
|
|
|
2019-11-20 23:16:01 +08:00
|
|
|
private $news;
|
|
|
|
|
|
|
|
public function __construct(News $news)
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$this->news = $news;
|
|
|
|
$this->setMailable(
|
|
|
|
$news->subject,
|
2021-04-12 02:32:58 +08:00
|
|
|
'notifications.mail.news.news',
|
2019-11-20 23:16:01 +08:00
|
|
|
['news' => $news]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the array representation of the notification.
|
|
|
|
*
|
|
|
|
* @param mixed $notifiable
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function toArray($notifiable)
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'news_id' => $this->news->id,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|