Custom.php 953 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 toCustom($notifiable)
  29. {
  30. return [
  31. 'title' => $this->title,
  32. 'content' => $this->content,
  33. ];
  34. }
  35. }