|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace App\Notifications; |
| 4 | + |
| 5 | +use FontLib\Table\Type\name; |
| 6 | +use Illuminate\Bus\Queueable; |
| 7 | +use Illuminate\Notifications\Notification; |
| 8 | +use Illuminate\Contracts\Queue\ShouldQueue; |
| 9 | +use Illuminate\Notifications\Messages\MailMessage; |
| 10 | + |
| 11 | +class NewOrder extends Notification |
| 12 | +{ |
| 13 | + use Queueable; |
| 14 | + |
| 15 | + public $order; |
| 16 | + /** |
| 17 | + * Create a new notification instance. |
| 18 | + * |
| 19 | + * @return void |
| 20 | + */ |
| 21 | + public function __construct($order) |
| 22 | + { |
| 23 | + // |
| 24 | + $this->order= $order; |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Get the notification's delivery channels. |
| 29 | + * |
| 30 | + * @param mixed $notifiable |
| 31 | + * @return array |
| 32 | + */ |
| 33 | + public function via($notifiable) |
| 34 | + { |
| 35 | + $notification_channel = 'database'; |
| 36 | + $channel = explode(',' , $notification_channel); |
| 37 | + return $channel; |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * Get the mail representation of the notification. |
| 42 | + * |
| 43 | + * @param mixed $notifiable |
| 44 | + * @return \Illuminate\Notifications\Messages\MailMessage |
| 45 | + */ |
| 46 | + public function toMail($notifiable) |
| 47 | + { |
| 48 | + return (new MailMessage) |
| 49 | + ->line('The introduction to the notification.') |
| 50 | + ->action('Notification Action', url('/')) |
| 51 | + ->line('Thank you for using our application!'); |
| 52 | + } |
| 53 | + |
| 54 | + public function toDatabase($notifiable) |
| 55 | + { |
| 56 | + return [ |
| 57 | + 'data' => 'Thare is new Order ('.$this->order->user->name.') With Number (#'.$this->order->id.')', |
| 58 | + 'url' => URL('/'), |
| 59 | + ]; |
| 60 | + } |
| 61 | + /** |
| 62 | + * Get the array representation of the notification. |
| 63 | + * |
| 64 | + * @param mixed $notifiable |
| 65 | + * @return array |
| 66 | + */ |
| 67 | + public function toArray($notifiable) |
| 68 | + { |
| 69 | + return [ |
| 70 | + // |
| 71 | + ]; |
| 72 | + } |
| 73 | +} |
0 commit comments