diff --git a/src/Illuminate/Foundation/Console/NotificationMakeCommand.php b/src/Illuminate/Foundation/Console/NotificationMakeCommand.php index 3156131b7a13..2fa534728365 100644 --- a/src/Illuminate/Foundation/Console/NotificationMakeCommand.php +++ b/src/Illuminate/Foundation/Console/NotificationMakeCommand.php @@ -100,6 +100,12 @@ protected function buildClass($name) */ protected function getStub() { + if ($this->option('queued')) { + return $this->option('markdown') + ? $this->resolveStubPath('/stubs/markdown-notification.queued.stub') + : $this->resolveStubPath('/stubs/notification.queued.stub'); + } + return $this->option('markdown') ? $this->resolveStubPath('/stubs/markdown-notification.stub') : $this->resolveStubPath('/stubs/notification.stub'); @@ -166,6 +172,7 @@ protected function getOptions() return [ ['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the notification already exists'], ['markdown', 'm', InputOption::VALUE_OPTIONAL, 'Create a new Markdown template for the notification'], + ['queued', null, InputOption::VALUE_NONE, 'Indicates the notification should be queued'], ]; } } diff --git a/src/Illuminate/Foundation/Console/stubs/markdown-notification.queued.stub b/src/Illuminate/Foundation/Console/stubs/markdown-notification.queued.stub new file mode 100644 index 000000000000..493011622fff --- /dev/null +++ b/src/Illuminate/Foundation/Console/stubs/markdown-notification.queued.stub @@ -0,0 +1,51 @@ + + */ + public function via(object $notifiable): array + { + return ['mail']; + } + + /** + * Get the mail representation of the notification. + */ + public function toMail(object $notifiable): MailMessage + { + return (new MailMessage)->markdown('{{ view }}'); + } + + /** + * Get the array representation of the notification. + * + * @return array + */ + public function toArray(object $notifiable): array + { + return [ + // + ]; + } +} diff --git a/src/Illuminate/Foundation/Console/stubs/markdown-notification.stub b/src/Illuminate/Foundation/Console/stubs/markdown-notification.stub index cc99eac88be6..2a945b339a80 100644 --- a/src/Illuminate/Foundation/Console/stubs/markdown-notification.stub +++ b/src/Illuminate/Foundation/Console/stubs/markdown-notification.stub @@ -2,15 +2,11 @@ namespace {{ namespace }}; -use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; class {{ class }} extends Notification { - use Queueable; - /** * Create a new notification instance. */ diff --git a/src/Illuminate/Foundation/Console/stubs/notification.queued.stub b/src/Illuminate/Foundation/Console/stubs/notification.queued.stub new file mode 100644 index 000000000000..32a43bfc6f8a --- /dev/null +++ b/src/Illuminate/Foundation/Console/stubs/notification.queued.stub @@ -0,0 +1,54 @@ + + */ + public function via(object $notifiable): array + { + return ['mail']; + } + + /** + * Get the mail representation of the notification. + */ + public function toMail(object $notifiable): MailMessage + { + return (new MailMessage) + ->line('The introduction to the notification.') + ->action('Notification Action', url('/')) + ->line('Thank you for using our application!'); + } + + /** + * Get the array representation of the notification. + * + * @return array + */ + public function toArray(object $notifiable): array + { + return [ + // + ]; + } +} diff --git a/src/Illuminate/Foundation/Console/stubs/notification.stub b/src/Illuminate/Foundation/Console/stubs/notification.stub index ee32826b70a5..22ae509639e8 100644 --- a/src/Illuminate/Foundation/Console/stubs/notification.stub +++ b/src/Illuminate/Foundation/Console/stubs/notification.stub @@ -2,15 +2,11 @@ namespace {{ namespace }}; -use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; class {{ class }} extends Notification { - use Queueable; - /** * Create a new notification instance. */