Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Illuminate/Foundation/Console/NotificationMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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'],
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace {{ namespace }};

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class {{ class }} extends Notification implements ShouldQueue
{
use Queueable;

/**
* Create a new notification instance.
*/
public function __construct()
{
//
}

/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
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<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
//
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
54 changes: 54 additions & 0 deletions src/Illuminate/Foundation/Console/stubs/notification.queued.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace {{ namespace }};

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class {{ class }} extends Notification implements ShouldQueue
{
use Queueable;

/**
* Create a new notification instance.
*/
public function __construct()
{
//
}

/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
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<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
//
];
}
}
4 changes: 0 additions & 4 deletions src/Illuminate/Foundation/Console/stubs/notification.stub
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down