OrderNotification.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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\Order;
  8. class OrderNotification extends Notification
  9. {
  10. use Queueable;
  11. protected $order_notification;
  12. /**
  13. * Create a new notification instance.
  14. *
  15. * @return void
  16. */
  17. public function __construct($order_notification)
  18. {
  19. $this->order_notification = $order_notification;
  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 ['mail', 'database'];
  30. return ['database'];
  31. }
  32. /**
  33. * Get the mail representation of the notification.
  34. *
  35. * @param mixed $notifiable
  36. * @return \Illuminate\Notifications\Messages\MailMessage
  37. */
  38. public function toMail($notifiable)
  39. {
  40. return (new MailMessage)
  41. ->line('The introduction to the notification.')
  42. ->action('Notification Action', url('/'))
  43. ->line('Thank you for using our application!');
  44. }
  45. /**
  46. * Get the array representation of the notification.
  47. *
  48. * @param mixed $notifiable
  49. * @return array
  50. */
  51. public function toArray($notifiable)
  52. {
  53. return [
  54. 'order_id' => $this->order_notification['order_id'],
  55. 'order_code' => $this->order_notification['order_code'],
  56. 'user_id' => $this->order_notification['user_id'],
  57. 'seller_id' => $this->order_notification['seller_id'],
  58. 'status' => $this->order_notification['status']
  59. ];
  60. }
  61. }