| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace App\Notifications;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Notifications\Messages\MailMessage;
- use Illuminate\Notifications\Notification;
- class SendEmailNotification extends Notification implements ShouldQueue
- {
- use Queueable;
- public $objToJson;
- public $view;
- /**
- * SendEmailNotification constructor.
- * @param $objToJson
- * @param $view
- */
- public function __construct($objToJson, $view)
- {
- $this->objToJson = $objToJson;
- $this->view = $view;
- }
- /**
- * Get the notification's delivery channels.
- *
- * @param mixed $notifiable
- * @return array
- */
- public function via($notifiable): array
- {
- return ['mail'];
- }
- /**
- * Get the mail representation of the notification.
- *
- * @param mixed $notifiable
- * @return MailMessage
- */
- public function toMail($notifiable): MailMessage
- {
- $template = json_decode($this->objToJson);
- $view = $this->view ? $this->view : 'emails.test';
- return (new MailMessage)->view(
- $view, ['objToJson' => $template]
- )->subject($template->title);
- }
- /**
- * Get the array representation of the notification.
- *
- * @param mixed $notifiable
- * @return array
- */
- public function toArray($notifiable)
- {
- return [
- //
- ];
- }
- }
|