1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sfneal\PostOffice\Notifications; |
4
|
|
|
|
5
|
|
|
use Illuminate\Bus\Queueable; |
6
|
|
|
use Illuminate\Bus\Queueable as QueueableTrait; |
7
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue; |
8
|
|
|
use Illuminate\Notifications\Messages\MailMessage; |
9
|
|
|
use Illuminate\Queue\InteractsWithQueue; |
10
|
|
|
use Illuminate\Queue\SerializesModels; |
11
|
|
|
use Sfneal\PostOffice\Mailables\Mailable; |
12
|
|
|
|
13
|
|
|
abstract class Notification extends \Illuminate\Notifications\Notification implements ShouldQueue |
14
|
|
|
{ |
15
|
|
|
use Queueable, InteractsWithQueue, QueueableTrait, SerializesModels; |
|
|
|
|
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var array channels to send notification via |
19
|
|
|
*/ |
20
|
|
|
private const VIA = ['mail']; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var array channels to send notification via |
24
|
|
|
*/ |
25
|
|
|
public $via; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Create a new notification instance. |
29
|
|
|
*/ |
30
|
|
|
public function __construct() |
31
|
|
|
{ |
32
|
|
|
$this->via = $this->via ?? ['mail']; |
33
|
|
|
$this->onQueue(config('post-office.queue')); |
34
|
|
|
$this->onConnection(config('post-office.driver')); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Get the notification's delivery channels. |
39
|
|
|
* |
40
|
|
|
* @param mixed $notifiable |
41
|
|
|
* @return array |
42
|
|
|
*/ |
43
|
|
|
public function via($notifiable): array |
|
|
|
|
44
|
|
|
{ |
45
|
|
|
return $this->via; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Get the mail representation of the notification. |
50
|
|
|
* |
51
|
|
|
* @param mixed $notifiable |
52
|
|
|
* @return MailMessage|Mailable |
53
|
|
|
*/ |
54
|
|
|
abstract public function toMail($notifiable); |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Get the array representation of the notification. |
58
|
|
|
* |
59
|
|
|
* @param mixed $notifiable |
60
|
|
|
* @return array |
61
|
|
|
*/ |
62
|
|
|
abstract public function toArray($notifiable): array; |
63
|
|
|
} |
64
|
|
|
|