PromotionNotification.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Notifications;
  3. use Illuminate\Bus\Queueable;
  4. use Illuminate\Contracts\Queue\ShouldQueue;
  5. use Illuminate\Notifications\Messages\MailMessage;
  6. use Illuminate\Notifications\Notification;
  7. use App\Models\Promotion;
  8. class PromotionNotification extends Notification
  9. {
  10. use Queueable;
  11. public $promo;
  12. /**
  13. * Create a new notification instance.
  14. *
  15. * @return void
  16. */
  17. public function __construct(Promotion $promo)
  18. {
  19. $this->promo = $promo;
  20. }
  21. /**
  22. * Get the notification's delivery channels.
  23. *
  24. * @param mixed $notifiable
  25. * @return array
  26. */
  27. public function via($notifiable)
  28. {
  29. return ['database'];
  30. }
  31. /**
  32. * Get the mail representation of the notification.
  33. *
  34. * @param mixed $notifiable
  35. * @return \Illuminate\Notifications\Messages\MailMessage
  36. */
  37. public function toMail($notifiable)
  38. {
  39. return (new MailMessage)
  40. ->line('The introduction to the notification.')
  41. ->action('Notification Action', url('/'))
  42. ->line('Thank you for using our application!');
  43. }
  44. /**
  45. * Get the array representation of the notification.
  46. *
  47. * @param mixed $notifiable
  48. * @return array
  49. */
  50. public function toArray($notifiable)
  51. {
  52. return [
  53. 'promo_id' =>$this->promo->id
  54. ];
  55. }
  56. }