Custom.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace App\Notifications;
  3. use App\Channels\BarkChannel;
  4. use Illuminate\Bus\Queueable;
  5. use Illuminate\Contracts\Queue\ShouldQueue;
  6. use Illuminate\Notifications\Messages\MailMessage;
  7. use Illuminate\Notifications\Notification;
  8. class Custom extends Notification implements ShouldQueue
  9. {
  10. use Queueable;
  11. private $title;
  12. private $content;
  13. public function __construct($title, $content)
  14. {
  15. $this->title = $title;
  16. $this->content = $content;
  17. }
  18. public function via($notifiable)
  19. {
  20. return $notifiable ?? ['mail', BarkChannel::class];
  21. }
  22. public function toMail($notifiable)
  23. {
  24. return (new MailMessage)
  25. ->subject($this->title)
  26. ->markdown('mail.custom', ['content' => $this->content]);
  27. }
  28. public function toArray($notifiable)
  29. {
  30. return [
  31. 'title' => $this->title,
  32. 'content' => $this->content,
  33. ];
  34. }
  35. public function toCustom($notifiable)
  36. {
  37. return [
  38. 'title' => $this->title,
  39. 'content' => $this->content,
  40. ];
  41. }
  42. }