Pressroom template verwijderd, website naar root van repo
This commit is contained in:
33
vendor/laravel/framework/src/Illuminate/Notifications/Action.php
vendored
Normal file
33
vendor/laravel/framework/src/Illuminate/Notifications/Action.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications;
|
||||
|
||||
class Action
|
||||
{
|
||||
/**
|
||||
* The action text.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $text;
|
||||
|
||||
/**
|
||||
* The action URL.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* Create a new action instance.
|
||||
*
|
||||
* @param string $text
|
||||
* @param string $url
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($text, $url)
|
||||
{
|
||||
$this->url = $url;
|
||||
$this->text = $text;
|
||||
}
|
||||
}
|
||||
174
vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php
vendored
Normal file
174
vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications;
|
||||
|
||||
use Illuminate\Mail\Markdown;
|
||||
use InvalidArgumentException;
|
||||
use Illuminate\Support\Manager;
|
||||
use Nexmo\Client as NexmoClient;
|
||||
use GuzzleHttp\Client as HttpClient;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Contracts\Bus\Dispatcher as Bus;
|
||||
use Nexmo\Client\Credentials\Basic as NexmoCredentials;
|
||||
use Illuminate\Contracts\Notifications\Factory as FactoryContract;
|
||||
use Illuminate\Contracts\Notifications\Dispatcher as DispatcherContract;
|
||||
|
||||
class ChannelManager extends Manager implements DispatcherContract, FactoryContract
|
||||
{
|
||||
/**
|
||||
* The default channel used to deliver messages.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $defaultChannel = 'mail';
|
||||
|
||||
/**
|
||||
* Send the given notification to the given notifiable entities.
|
||||
*
|
||||
* @param \Illuminate\Support\Collection|array|mixed $notifiables
|
||||
* @param mixed $notification
|
||||
* @return void
|
||||
*/
|
||||
public function send($notifiables, $notification)
|
||||
{
|
||||
return (new NotificationSender(
|
||||
$this, $this->app->make(Bus::class), $this->app->make(Dispatcher::class))
|
||||
)->send($notifiables, $notification);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given notification immediately.
|
||||
*
|
||||
* @param \Illuminate\Support\Collection|array|mixed $notifiables
|
||||
* @param mixed $notification
|
||||
* @param array|null $channels
|
||||
* @return void
|
||||
*/
|
||||
public function sendNow($notifiables, $notification, array $channels = null)
|
||||
{
|
||||
return (new NotificationSender(
|
||||
$this, $this->app->make(Bus::class), $this->app->make(Dispatcher::class))
|
||||
)->sendNow($notifiables, $notification, $channels);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a channel instance.
|
||||
*
|
||||
* @param string|null $name
|
||||
* @return mixed
|
||||
*/
|
||||
public function channel($name = null)
|
||||
{
|
||||
return $this->driver($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the database driver.
|
||||
*
|
||||
* @return \Illuminate\Notifications\Channels\DatabaseChannel
|
||||
*/
|
||||
protected function createDatabaseDriver()
|
||||
{
|
||||
return $this->app->make(Channels\DatabaseChannel::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the broadcast driver.
|
||||
*
|
||||
* @return \Illuminate\Notifications\Channels\BroadcastChannel
|
||||
*/
|
||||
protected function createBroadcastDriver()
|
||||
{
|
||||
return $this->app->make(Channels\BroadcastChannel::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the mail driver.
|
||||
*
|
||||
* @return \Illuminate\Notifications\Channels\MailChannel
|
||||
*/
|
||||
protected function createMailDriver()
|
||||
{
|
||||
return $this->app->make(Channels\MailChannel::class)->setMarkdownResolver(function () {
|
||||
return $this->app->make(Markdown::class);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the Nexmo driver.
|
||||
*
|
||||
* @return \Illuminate\Notifications\Channels\NexmoSmsChannel
|
||||
*/
|
||||
protected function createNexmoDriver()
|
||||
{
|
||||
return new Channels\NexmoSmsChannel(
|
||||
new NexmoClient(new NexmoCredentials(
|
||||
$this->app['config']['services.nexmo.key'],
|
||||
$this->app['config']['services.nexmo.secret']
|
||||
)),
|
||||
$this->app['config']['services.nexmo.sms_from']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the Slack driver.
|
||||
*
|
||||
* @return \Illuminate\Notifications\Channels\SlackWebhookChannel
|
||||
*/
|
||||
protected function createSlackDriver()
|
||||
{
|
||||
return new Channels\SlackWebhookChannel(new HttpClient);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new driver instance.
|
||||
*
|
||||
* @param string $driver
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function createDriver($driver)
|
||||
{
|
||||
try {
|
||||
return parent::createDriver($driver);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
if (class_exists($driver)) {
|
||||
return $this->app->make($driver);
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default channel driver name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultDriver()
|
||||
{
|
||||
return $this->defaultChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default channel driver name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function deliversVia()
|
||||
{
|
||||
return $this->getDefaultDriver();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default channel driver name.
|
||||
*
|
||||
* @param string $channel
|
||||
* @return void
|
||||
*/
|
||||
public function deliverVia($channel)
|
||||
{
|
||||
$this->defaultChannel = $channel;
|
||||
}
|
||||
}
|
||||
77
vendor/laravel/framework/src/Illuminate/Notifications/Channels/BroadcastChannel.php
vendored
Normal file
77
vendor/laravel/framework/src/Illuminate/Notifications/Channels/BroadcastChannel.php
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Channels;
|
||||
|
||||
use RuntimeException;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Notifications\Messages\BroadcastMessage;
|
||||
use Illuminate\Notifications\Events\BroadcastNotificationCreated;
|
||||
|
||||
class BroadcastChannel
|
||||
{
|
||||
/**
|
||||
* The event dispatcher.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Events\Dispatcher
|
||||
*/
|
||||
protected $events;
|
||||
|
||||
/**
|
||||
* Create a new database channel.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Events\Dispatcher $events
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Dispatcher $events)
|
||||
{
|
||||
$this->events = $events;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @param \Illuminate\Notifications\Notification $notification
|
||||
* @return array|null
|
||||
*/
|
||||
public function send($notifiable, Notification $notification)
|
||||
{
|
||||
$message = $this->getData($notifiable, $notification);
|
||||
|
||||
$event = new BroadcastNotificationCreated(
|
||||
$notifiable, $notification, is_array($message) ? $message : $message->data
|
||||
);
|
||||
|
||||
if ($message instanceof BroadcastMessage) {
|
||||
$event->onConnection($message->connection)
|
||||
->onQueue($message->queue);
|
||||
}
|
||||
|
||||
return $this->events->dispatch($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data for the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @param \Illuminate\Notifications\Notification $notification
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function getData($notifiable, Notification $notification)
|
||||
{
|
||||
if (method_exists($notification, 'toBroadcast')) {
|
||||
return $notification->toBroadcast($notifiable);
|
||||
}
|
||||
|
||||
if (method_exists($notification, 'toArray')) {
|
||||
return $notification->toArray($notifiable);
|
||||
}
|
||||
|
||||
throw new RuntimeException(
|
||||
'Notification is missing toArray method.'
|
||||
);
|
||||
}
|
||||
}
|
||||
51
vendor/laravel/framework/src/Illuminate/Notifications/Channels/DatabaseChannel.php
vendored
Normal file
51
vendor/laravel/framework/src/Illuminate/Notifications/Channels/DatabaseChannel.php
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Channels;
|
||||
|
||||
use RuntimeException;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class DatabaseChannel
|
||||
{
|
||||
/**
|
||||
* Send the given notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @param \Illuminate\Notifications\Notification $notification
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
public function send($notifiable, Notification $notification)
|
||||
{
|
||||
return $notifiable->routeNotificationFor('database')->create([
|
||||
'id' => $notification->id,
|
||||
'type' => get_class($notification),
|
||||
'data' => $this->getData($notifiable, $notification),
|
||||
'read_at' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data for the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @param \Illuminate\Notifications\Notification $notification
|
||||
* @return array
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function getData($notifiable, Notification $notification)
|
||||
{
|
||||
if (method_exists($notification, 'toDatabase')) {
|
||||
return is_array($data = $notification->toDatabase($notifiable))
|
||||
? $data : $data->data;
|
||||
}
|
||||
|
||||
if (method_exists($notification, 'toArray')) {
|
||||
return $notification->toArray($notifiable);
|
||||
}
|
||||
|
||||
throw new RuntimeException(
|
||||
'Notification is missing toDatabase / toArray method.'
|
||||
);
|
||||
}
|
||||
}
|
||||
196
vendor/laravel/framework/src/Illuminate/Notifications/Channels/MailChannel.php
vendored
Normal file
196
vendor/laravel/framework/src/Illuminate/Notifications/Channels/MailChannel.php
vendored
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Channels;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Contracts\Mail\Mailer;
|
||||
use Illuminate\Contracts\Mail\Mailable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class MailChannel
|
||||
{
|
||||
/**
|
||||
* The mailer implementation.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Mail\Mailer
|
||||
*/
|
||||
protected $mailer;
|
||||
|
||||
/**
|
||||
* The Markdown resolver callback.
|
||||
*
|
||||
* @var \Closure
|
||||
*/
|
||||
protected $markdownResolver;
|
||||
|
||||
/**
|
||||
* Create a new mail channel instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Mail\Mailer $mailer
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Mailer $mailer)
|
||||
{
|
||||
$this->mailer = $mailer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @param \Illuminate\Notifications\Notification $notification
|
||||
* @return void
|
||||
*/
|
||||
public function send($notifiable, Notification $notification)
|
||||
{
|
||||
if (! $notifiable->routeNotificationFor('mail')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$message = $notification->toMail($notifiable);
|
||||
|
||||
if ($message instanceof Mailable) {
|
||||
return $message->send($this->mailer);
|
||||
}
|
||||
|
||||
$this->mailer->send($this->buildView($message), $message->data(), function ($mailMessage) use ($notifiable, $notification, $message) {
|
||||
$this->buildMessage($mailMessage, $notifiable, $notification, $message);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the notification's view.
|
||||
*
|
||||
* @param \Illuminate\Notifications\Messages\MailMessage $message
|
||||
* @return void
|
||||
*/
|
||||
protected function buildView($message)
|
||||
{
|
||||
if ($message->view) {
|
||||
return $message->view;
|
||||
}
|
||||
|
||||
$markdown = call_user_func($this->markdownResolver);
|
||||
|
||||
return [
|
||||
'html' => $markdown->render($message->markdown, $message->data()),
|
||||
'text' => $markdown->renderText($message->markdown, $message->data()),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the mail message.
|
||||
*
|
||||
* @param \Illuminate\Mail\Message $mailMessage
|
||||
* @param mixed $notifiable
|
||||
* @param \Illuminate\Notifications\Notification $notification
|
||||
* @param \Illuminate\Notifications\Messages\MailMessage $message
|
||||
* @return void
|
||||
*/
|
||||
protected function buildMessage($mailMessage, $notifiable, $notification, $message)
|
||||
{
|
||||
$this->addressMessage($mailMessage, $notifiable, $message);
|
||||
|
||||
$mailMessage->subject($message->subject ?: Str::title(
|
||||
Str::snake(class_basename($notification), ' ')
|
||||
));
|
||||
|
||||
$this->addAttachments($mailMessage, $message);
|
||||
|
||||
if (! is_null($message->priority)) {
|
||||
$mailMessage->setPriority($message->priority);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Address the mail message.
|
||||
*
|
||||
* @param \Illuminate\Mail\Message $mailMessage
|
||||
* @param mixed $notifiable
|
||||
* @param \Illuminate\Notifications\Messages\MailMessage $message
|
||||
* @return void
|
||||
*/
|
||||
protected function addressMessage($mailMessage, $notifiable, $message)
|
||||
{
|
||||
$this->addSender($mailMessage, $message);
|
||||
|
||||
$mailMessage->to($this->getRecipients($notifiable, $message));
|
||||
|
||||
if ($message->cc) {
|
||||
$mailMessage->cc($message->cc[0], Arr::get($message->cc, 1));
|
||||
}
|
||||
|
||||
if ($message->bcc) {
|
||||
$mailMessage->bcc($message->bcc[0], Arr::get($message->bcc, 1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the "from" and "reply to" addresses to the message.
|
||||
*
|
||||
* @param \Illuminate\Mail\Message $mailMessage
|
||||
* @param \Illuminate\Notifications\Messages\MailMessage $message
|
||||
* @return void
|
||||
*/
|
||||
protected function addSender($mailMessage, $message)
|
||||
{
|
||||
if (! empty($message->from)) {
|
||||
$mailMessage->from($message->from[0], Arr::get($message->from, 1));
|
||||
}
|
||||
|
||||
if (! empty($message->replyTo)) {
|
||||
$mailMessage->replyTo($message->replyTo[0], Arr::get($message->replyTo, 1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the recipients of the given message.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @param \Illuminate\Notifications\Messages\MailMessage $message
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getRecipients($notifiable, $message)
|
||||
{
|
||||
if (is_string($recipients = $notifiable->routeNotificationFor('mail'))) {
|
||||
$recipients = [$recipients];
|
||||
}
|
||||
|
||||
return collect($recipients)->map(function ($recipient) {
|
||||
return is_string($recipient) ? $recipient : $recipient->email;
|
||||
})->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the attachments to the message.
|
||||
*
|
||||
* @param \Illuminate\Mail\Message $mailMessage
|
||||
* @param \Illuminate\Notifications\Messages\MailMessage $message
|
||||
* @return void
|
||||
*/
|
||||
protected function addAttachments($mailMessage, $message)
|
||||
{
|
||||
foreach ($message->attachments as $attachment) {
|
||||
$mailMessage->attach($attachment['file'], $attachment['options']);
|
||||
}
|
||||
|
||||
foreach ($message->rawAttachments as $attachment) {
|
||||
$mailMessage->attachData($attachment['data'], $attachment['name'], $attachment['options']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Markdown resolver callback.
|
||||
*
|
||||
* @param \Closure $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function setMarkdownResolver(Closure $callback)
|
||||
{
|
||||
$this->markdownResolver = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
64
vendor/laravel/framework/src/Illuminate/Notifications/Channels/NexmoSmsChannel.php
vendored
Normal file
64
vendor/laravel/framework/src/Illuminate/Notifications/Channels/NexmoSmsChannel.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Channels;
|
||||
|
||||
use Nexmo\Client as NexmoClient;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Notifications\Messages\NexmoMessage;
|
||||
|
||||
class NexmoSmsChannel
|
||||
{
|
||||
/**
|
||||
* The Nexmo client instance.
|
||||
*
|
||||
* @var \Nexmo\Client
|
||||
*/
|
||||
protected $nexmo;
|
||||
|
||||
/**
|
||||
* The phone number notifications should be sent from.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $from;
|
||||
|
||||
/**
|
||||
* Create a new Nexmo channel instance.
|
||||
*
|
||||
* @param \Nexmo\Client $nexmo
|
||||
* @param string $from
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(NexmoClient $nexmo, $from)
|
||||
{
|
||||
$this->from = $from;
|
||||
$this->nexmo = $nexmo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @param \Illuminate\Notifications\Notification $notification
|
||||
* @return \Nexmo\Message\Message
|
||||
*/
|
||||
public function send($notifiable, Notification $notification)
|
||||
{
|
||||
if (! $to = $notifiable->routeNotificationFor('nexmo')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$message = $notification->toNexmo($notifiable);
|
||||
|
||||
if (is_string($message)) {
|
||||
$message = new NexmoMessage($message);
|
||||
}
|
||||
|
||||
return $this->nexmo->message()->send([
|
||||
'type' => $message->type,
|
||||
'from' => $message->from ?: $this->from,
|
||||
'to' => $to,
|
||||
'text' => trim($message->content),
|
||||
]);
|
||||
}
|
||||
}
|
||||
114
vendor/laravel/framework/src/Illuminate/Notifications/Channels/SlackWebhookChannel.php
vendored
Normal file
114
vendor/laravel/framework/src/Illuminate/Notifications/Channels/SlackWebhookChannel.php
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Channels;
|
||||
|
||||
use GuzzleHttp\Client as HttpClient;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Messages\SlackAttachment;
|
||||
use Illuminate\Notifications\Messages\SlackAttachmentField;
|
||||
|
||||
class SlackWebhookChannel
|
||||
{
|
||||
/**
|
||||
* The HTTP client instance.
|
||||
*
|
||||
* @var \GuzzleHttp\Client
|
||||
*/
|
||||
protected $http;
|
||||
|
||||
/**
|
||||
* Create a new Slack channel instance.
|
||||
*
|
||||
* @param \GuzzleHttp\Client $http
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(HttpClient $http)
|
||||
{
|
||||
$this->http = $http;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @param \Illuminate\Notifications\Notification $notification
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function send($notifiable, Notification $notification)
|
||||
{
|
||||
if (! $url = $notifiable->routeNotificationFor('slack')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->http->post($url, $this->buildJsonPayload(
|
||||
$notification->toSlack($notifiable)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build up a JSON payload for the Slack webhook.
|
||||
*
|
||||
* @param \Illuminate\Notifications\Messages\SlackMessage $message
|
||||
* @return array
|
||||
*/
|
||||
protected function buildJsonPayload(SlackMessage $message)
|
||||
{
|
||||
$optionalFields = array_filter([
|
||||
'channel' => data_get($message, 'channel'),
|
||||
'icon_emoji' => data_get($message, 'icon'),
|
||||
'icon_url' => data_get($message, 'image'),
|
||||
'link_names' => data_get($message, 'linkNames'),
|
||||
'username' => data_get($message, 'username'),
|
||||
]);
|
||||
|
||||
return array_merge([
|
||||
'json' => array_merge([
|
||||
'text' => $message->content,
|
||||
'attachments' => $this->attachments($message),
|
||||
], $optionalFields),
|
||||
], $message->http);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the message's attachments.
|
||||
*
|
||||
* @param \Illuminate\Notifications\Messages\SlackMessage $message
|
||||
* @return array
|
||||
*/
|
||||
protected function attachments(SlackMessage $message)
|
||||
{
|
||||
return collect($message->attachments)->map(function ($attachment) use ($message) {
|
||||
return array_filter([
|
||||
'color' => $attachment->color ?: $message->color(),
|
||||
'fallback' => $attachment->fallback,
|
||||
'fields' => $this->fields($attachment),
|
||||
'footer' => $attachment->footer,
|
||||
'footer_icon' => $attachment->footerIcon,
|
||||
'image_url' => $attachment->imageUrl,
|
||||
'mrkdwn_in' => $attachment->markdown,
|
||||
'text' => $attachment->content,
|
||||
'title' => $attachment->title,
|
||||
'title_link' => $attachment->url,
|
||||
'ts' => $attachment->timestamp,
|
||||
]);
|
||||
})->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the attachment's fields.
|
||||
*
|
||||
* @param \Illuminate\Notifications\Messages\SlackAttachment $attachment
|
||||
* @return array
|
||||
*/
|
||||
protected function fields(SlackAttachment $attachment)
|
||||
{
|
||||
return collect($attachment->fields)->map(function ($value, $key) {
|
||||
if ($value instanceof SlackAttachmentField) {
|
||||
return $value->toArray();
|
||||
}
|
||||
|
||||
return ['title' => $key, 'value' => $value, 'short' => true];
|
||||
})->values()->all();
|
||||
}
|
||||
}
|
||||
81
vendor/laravel/framework/src/Illuminate/Notifications/Console/NotificationTableCommand.php
vendored
Normal file
81
vendor/laravel/framework/src/Illuminate/Notifications/Console/NotificationTableCommand.php
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Composer;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
|
||||
class NotificationTableCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'notifications:table';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a migration for the notifications table';
|
||||
|
||||
/**
|
||||
* The filesystem instance.
|
||||
*
|
||||
* @var \Illuminate\Filesystem\Filesystem
|
||||
*/
|
||||
protected $files;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Support\Composer
|
||||
*/
|
||||
protected $composer;
|
||||
|
||||
/**
|
||||
* Create a new notifications table command instance.
|
||||
*
|
||||
* @param \Illuminate\Filesystem\Filesystem $files
|
||||
* @param \Illuminate\Support\Composer $composer
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Filesystem $files, Composer $composer)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->files = $files;
|
||||
$this->composer = $composer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
$fullPath = $this->createBaseMigration();
|
||||
|
||||
$this->files->put($fullPath, $this->files->get(__DIR__.'/stubs/notifications.stub'));
|
||||
|
||||
$this->info('Migration created successfully!');
|
||||
|
||||
$this->composer->dumpAutoloads();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a base migration file for the notifications.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createBaseMigration()
|
||||
{
|
||||
$name = 'create_notifications_table';
|
||||
|
||||
$path = $this->laravel->databasePath().'/migrations';
|
||||
|
||||
return $this->laravel['migration.creator']->create($name, $path);
|
||||
}
|
||||
}
|
||||
35
vendor/laravel/framework/src/Illuminate/Notifications/Console/stubs/notifications.stub
vendored
Normal file
35
vendor/laravel/framework/src/Illuminate/Notifications/Console/stubs/notifications.stub
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateNotificationsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('notifications', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->string('type');
|
||||
$table->morphs('notifiable');
|
||||
$table->text('data');
|
||||
$table->timestamp('read_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('notifications');
|
||||
}
|
||||
}
|
||||
90
vendor/laravel/framework/src/Illuminate/Notifications/DatabaseNotification.php
vendored
Normal file
90
vendor/laravel/framework/src/Illuminate/Notifications/DatabaseNotification.php
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DatabaseNotification extends Model
|
||||
{
|
||||
/**
|
||||
* Indicates if the IDs are auto-incrementing.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $incrementing = false;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'notifications';
|
||||
|
||||
/**
|
||||
* The guarded attributes on the model.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'data' => 'array',
|
||||
'read_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the notifiable entity that the notification belongs to.
|
||||
*/
|
||||
public function notifiable()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the notification as read.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function markAsRead()
|
||||
{
|
||||
if (is_null($this->read_at)) {
|
||||
$this->forceFill(['read_at' => $this->freshTimestamp()])->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a notification has been read.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function read()
|
||||
{
|
||||
return $this->read_at !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a notification has not been read.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function unread()
|
||||
{
|
||||
return $this->read_at === null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new database notification collection instance.
|
||||
*
|
||||
* @param array $models
|
||||
* @return \Illuminate\Notifications\DatabaseNotificationCollection
|
||||
*/
|
||||
public function newCollection(array $models = [])
|
||||
{
|
||||
return new DatabaseNotificationCollection($models);
|
||||
}
|
||||
}
|
||||
20
vendor/laravel/framework/src/Illuminate/Notifications/DatabaseNotificationCollection.php
vendored
Normal file
20
vendor/laravel/framework/src/Illuminate/Notifications/DatabaseNotificationCollection.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class DatabaseNotificationCollection extends Collection
|
||||
{
|
||||
/**
|
||||
* Mark all notification as read.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function markAsRead()
|
||||
{
|
||||
$this->each(function ($notification) {
|
||||
$notification->markAsRead();
|
||||
});
|
||||
}
|
||||
}
|
||||
94
vendor/laravel/framework/src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php
vendored
Normal file
94
vendor/laravel/framework/src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Events;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
|
||||
class BroadcastNotificationCreated implements ShouldBroadcast
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* The notifiable entity who received the notification.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $notifiable;
|
||||
|
||||
/**
|
||||
* The notification instance.
|
||||
*
|
||||
* @var \Illuminate\Notifications\Notification
|
||||
*/
|
||||
public $notification;
|
||||
|
||||
/**
|
||||
* The notification data.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $data = [];
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @param \Illuminate\Notifications\Notification $notification
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($notifiable, $notification, $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->notifiable = $notifiable;
|
||||
$this->notification = $notification;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
$channels = $this->notification->broadcastOn();
|
||||
|
||||
if (! empty($channels)) {
|
||||
return $channels;
|
||||
}
|
||||
|
||||
return [new PrivateChannel($this->channelName())];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data that should be sent with the broadcasted event.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function broadcastWith()
|
||||
{
|
||||
return array_merge($this->data, [
|
||||
'id' => $this->notification->id,
|
||||
'type' => get_class($this->notification),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the broadcast channel name for the event.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function channelName()
|
||||
{
|
||||
if (method_exists($this->notifiable, 'receivesBroadcastNotificationsOn')) {
|
||||
return $this->notifiable->receivesBroadcastNotificationsOn($this->notification);
|
||||
}
|
||||
|
||||
$class = str_replace('\\', '.', get_class($this->notifiable));
|
||||
|
||||
return $class.'.'.$this->notifiable->getKey();
|
||||
}
|
||||
}
|
||||
51
vendor/laravel/framework/src/Illuminate/Notifications/Events/NotificationFailed.php
vendored
Normal file
51
vendor/laravel/framework/src/Illuminate/Notifications/Events/NotificationFailed.php
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Events;
|
||||
|
||||
class NotificationFailed
|
||||
{
|
||||
/**
|
||||
* The notifiable entity who received the notification.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $notifiable;
|
||||
|
||||
/**
|
||||
* The notification instance.
|
||||
*
|
||||
* @var \Illuminate\Notifications\Notification
|
||||
*/
|
||||
public $notification;
|
||||
|
||||
/**
|
||||
* The channel name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $channel;
|
||||
|
||||
/**
|
||||
* The data needed to process this failure.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $data = [];
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @param \Illuminate\Notifications\Notification $notification
|
||||
* @param string $channel
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($notifiable, $notification, $channel, $data = [])
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->channel = $channel;
|
||||
$this->notifiable = $notifiable;
|
||||
$this->notification = $notification;
|
||||
}
|
||||
}
|
||||
42
vendor/laravel/framework/src/Illuminate/Notifications/Events/NotificationSending.php
vendored
Normal file
42
vendor/laravel/framework/src/Illuminate/Notifications/Events/NotificationSending.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Events;
|
||||
|
||||
class NotificationSending
|
||||
{
|
||||
/**
|
||||
* The notifiable entity who received the notification.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $notifiable;
|
||||
|
||||
/**
|
||||
* The notification instance.
|
||||
*
|
||||
* @var \Illuminate\Notifications\Notification
|
||||
*/
|
||||
public $notification;
|
||||
|
||||
/**
|
||||
* The channel name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $channel;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @param \Illuminate\Notifications\Notification $notification
|
||||
* @param string $channel
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($notifiable, $notification, $channel)
|
||||
{
|
||||
$this->channel = $channel;
|
||||
$this->notifiable = $notifiable;
|
||||
$this->notification = $notification;
|
||||
}
|
||||
}
|
||||
51
vendor/laravel/framework/src/Illuminate/Notifications/Events/NotificationSent.php
vendored
Normal file
51
vendor/laravel/framework/src/Illuminate/Notifications/Events/NotificationSent.php
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Events;
|
||||
|
||||
class NotificationSent
|
||||
{
|
||||
/**
|
||||
* The notifiable entity who received the notification.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $notifiable;
|
||||
|
||||
/**
|
||||
* The notification instance.
|
||||
*
|
||||
* @var \Illuminate\Notifications\Notification
|
||||
*/
|
||||
public $notification;
|
||||
|
||||
/**
|
||||
* The channel name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $channel;
|
||||
|
||||
/**
|
||||
* The channel's response.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $response;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @param \Illuminate\Notifications\Notification $notification
|
||||
* @param string $channel
|
||||
* @param mixed $response
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($notifiable, $notification, $channel, $response = null)
|
||||
{
|
||||
$this->channel = $channel;
|
||||
$this->response = $response;
|
||||
$this->notifiable = $notifiable;
|
||||
$this->notification = $notification;
|
||||
}
|
||||
}
|
||||
33
vendor/laravel/framework/src/Illuminate/Notifications/HasDatabaseNotifications.php
vendored
Normal file
33
vendor/laravel/framework/src/Illuminate/Notifications/HasDatabaseNotifications.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications;
|
||||
|
||||
trait HasDatabaseNotifications
|
||||
{
|
||||
/**
|
||||
* Get the entity's notifications.
|
||||
*/
|
||||
public function notifications()
|
||||
{
|
||||
return $this->morphMany(DatabaseNotification::class, 'notifiable')
|
||||
->orderBy('created_at', 'desc');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entity's read notifications.
|
||||
*/
|
||||
public function readNotifications()
|
||||
{
|
||||
return $this->notifications()
|
||||
->whereNotNull('read_at');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entity's unread notifications.
|
||||
*/
|
||||
public function unreadNotifications()
|
||||
{
|
||||
return $this->notifications()
|
||||
->whereNull('read_at');
|
||||
}
|
||||
}
|
||||
41
vendor/laravel/framework/src/Illuminate/Notifications/Messages/BroadcastMessage.php
vendored
Normal file
41
vendor/laravel/framework/src/Illuminate/Notifications/Messages/BroadcastMessage.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Messages;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
|
||||
class BroadcastMessage
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* The data for the notification.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message data.
|
||||
*
|
||||
* @param array $data
|
||||
* @return $this
|
||||
*/
|
||||
public function data($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
24
vendor/laravel/framework/src/Illuminate/Notifications/Messages/DatabaseMessage.php
vendored
Normal file
24
vendor/laravel/framework/src/Illuminate/Notifications/Messages/DatabaseMessage.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Messages;
|
||||
|
||||
class DatabaseMessage
|
||||
{
|
||||
/**
|
||||
* The data that should be stored with the notification.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $data = [];
|
||||
|
||||
/**
|
||||
* Create a new database message.
|
||||
*
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(array $data = [])
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
}
|
||||
220
vendor/laravel/framework/src/Illuminate/Notifications/Messages/MailMessage.php
vendored
Normal file
220
vendor/laravel/framework/src/Illuminate/Notifications/Messages/MailMessage.php
vendored
Normal file
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Messages;
|
||||
|
||||
class MailMessage extends SimpleMessage
|
||||
{
|
||||
/**
|
||||
* The view to be rendered.
|
||||
*
|
||||
* @var array|string
|
||||
*/
|
||||
public $view;
|
||||
|
||||
/**
|
||||
* The view data for the message.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $viewData = [];
|
||||
|
||||
/**
|
||||
* The Markdown template to render (if applicable).
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $markdown = 'notifications::email';
|
||||
|
||||
/**
|
||||
* The "from" information for the message.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $from = [];
|
||||
|
||||
/**
|
||||
* The "reply to" information for the message.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $replyTo = [];
|
||||
|
||||
/**
|
||||
* The "cc" information for the message.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $cc = [];
|
||||
|
||||
/**
|
||||
* The "bcc" information for the message.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $bcc = [];
|
||||
|
||||
/**
|
||||
* The attachments for the message.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $attachments = [];
|
||||
|
||||
/**
|
||||
* The raw attachments for the message.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $rawAttachments = [];
|
||||
|
||||
/**
|
||||
* Priority level of the message.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $priority;
|
||||
|
||||
/**
|
||||
* Set the view for the mail message.
|
||||
*
|
||||
* @param array|string $view
|
||||
* @param array $data
|
||||
* @return $this
|
||||
*/
|
||||
public function view($view, array $data = [])
|
||||
{
|
||||
$this->view = $view;
|
||||
$this->viewData = $data;
|
||||
|
||||
$this->markdown = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Markdown template for the notification.
|
||||
*
|
||||
* @param string $view
|
||||
* @param array $data
|
||||
* @return $this
|
||||
*/
|
||||
public function markdown($view, array $data = [])
|
||||
{
|
||||
$this->markdown = $view;
|
||||
$this->viewData = $data;
|
||||
|
||||
$this->view = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the from address for the mail message.
|
||||
*
|
||||
* @param string $address
|
||||
* @param string|null $name
|
||||
* @return $this
|
||||
*/
|
||||
public function from($address, $name = null)
|
||||
{
|
||||
$this->from = [$address, $name];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the "reply to" address of the message.
|
||||
*
|
||||
* @param array|string $address
|
||||
* @param string|null $name
|
||||
* @return $this
|
||||
*/
|
||||
public function replyTo($address, $name = null)
|
||||
{
|
||||
$this->replyTo = [$address, $name];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cc address for the mail message.
|
||||
*
|
||||
* @param string $address
|
||||
* @param string|null $name
|
||||
* @return $this
|
||||
*/
|
||||
public function cc($address, $name = null)
|
||||
{
|
||||
$this->cc = [$address, $name];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bcc address for the mail message.
|
||||
*
|
||||
* @param string $address
|
||||
* @param string|null $name
|
||||
* @return $this
|
||||
*/
|
||||
public function bcc($address, $name = null)
|
||||
{
|
||||
$this->bcc = [$address, $name];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach a file to the message.
|
||||
*
|
||||
* @param string $file
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function attach($file, array $options = [])
|
||||
{
|
||||
$this->attachments[] = compact('file', 'options');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach in-memory data as an attachment.
|
||||
*
|
||||
* @param string $data
|
||||
* @param string $name
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function attachData($data, $name, array $options = [])
|
||||
{
|
||||
$this->rawAttachments[] = compact('data', 'name', 'options');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the priority of this message.
|
||||
*
|
||||
* The value is an integer where 1 is the highest priority and 5 is the lowest.
|
||||
*
|
||||
* @param int $level
|
||||
* @return $this
|
||||
*/
|
||||
public function priority($level)
|
||||
{
|
||||
$this->priority = $level;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data array for the mail message.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function data()
|
||||
{
|
||||
return array_merge($this->toArray(), $this->viewData);
|
||||
}
|
||||
}
|
||||
76
vendor/laravel/framework/src/Illuminate/Notifications/Messages/NexmoMessage.php
vendored
Normal file
76
vendor/laravel/framework/src/Illuminate/Notifications/Messages/NexmoMessage.php
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Messages;
|
||||
|
||||
class NexmoMessage
|
||||
{
|
||||
/**
|
||||
* The message content.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $content;
|
||||
|
||||
/**
|
||||
* The phone number the message should be sent from.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $from;
|
||||
|
||||
/**
|
||||
* The message type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'text';
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param string $content
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($content = '')
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message content.
|
||||
*
|
||||
* @param string $content
|
||||
* @return $this
|
||||
*/
|
||||
public function content($content)
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the phone number the message should be sent from.
|
||||
*
|
||||
* @param string $from
|
||||
* @return $this
|
||||
*/
|
||||
public function from($from)
|
||||
{
|
||||
$this->from = $from;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message type.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function unicode()
|
||||
{
|
||||
$this->type = 'unicode';
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
219
vendor/laravel/framework/src/Illuminate/Notifications/Messages/SimpleMessage.php
vendored
Normal file
219
vendor/laravel/framework/src/Illuminate/Notifications/Messages/SimpleMessage.php
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Messages;
|
||||
|
||||
use Illuminate\Notifications\Action;
|
||||
|
||||
class SimpleMessage
|
||||
{
|
||||
/**
|
||||
* The "level" of the notification (info, success, error).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $level = 'info';
|
||||
|
||||
/**
|
||||
* The subject of the notification.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $subject;
|
||||
|
||||
/**
|
||||
* The notification's greeting.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $greeting;
|
||||
|
||||
/**
|
||||
* The notification's salutation.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $salutation;
|
||||
|
||||
/**
|
||||
* The "intro" lines of the notification.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $introLines = [];
|
||||
|
||||
/**
|
||||
* The "outro" lines of the notification.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $outroLines = [];
|
||||
|
||||
/**
|
||||
* The text / label for the action.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $actionText;
|
||||
|
||||
/**
|
||||
* The action URL.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $actionUrl;
|
||||
|
||||
/**
|
||||
* Indicate that the notification gives information about a successful operation.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function success()
|
||||
{
|
||||
$this->level = 'success';
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the notification gives information about an error.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function error()
|
||||
{
|
||||
$this->level = 'error';
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the "level" of the notification (success, error, etc.).
|
||||
*
|
||||
* @param string $level
|
||||
* @return $this
|
||||
*/
|
||||
public function level($level)
|
||||
{
|
||||
$this->level = $level;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the subject of the notification.
|
||||
*
|
||||
* @param string $subject
|
||||
* @return $this
|
||||
*/
|
||||
public function subject($subject)
|
||||
{
|
||||
$this->subject = $subject;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the greeting of the notification.
|
||||
*
|
||||
* @param string $greeting
|
||||
* @return $this
|
||||
*/
|
||||
public function greeting($greeting)
|
||||
{
|
||||
$this->greeting = $greeting;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the salutation of the notification.
|
||||
*
|
||||
* @param string $salutation
|
||||
* @return $this
|
||||
*/
|
||||
public function salutation($salutation)
|
||||
{
|
||||
$this->salutation = $salutation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a line of text to the notification.
|
||||
*
|
||||
* @param \Illuminate\Notifications\Action|string $line
|
||||
* @return $this
|
||||
*/
|
||||
public function line($line)
|
||||
{
|
||||
return $this->with($line);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a line of text to the notification.
|
||||
*
|
||||
* @param \Illuminate\Notifications\Action|string|array $line
|
||||
* @return $this
|
||||
*/
|
||||
public function with($line)
|
||||
{
|
||||
if ($line instanceof Action) {
|
||||
$this->action($line->text, $line->url);
|
||||
} elseif (! $this->actionText) {
|
||||
$this->introLines[] = $this->formatLine($line);
|
||||
} else {
|
||||
$this->outroLines[] = $this->formatLine($line);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the given line of text.
|
||||
*
|
||||
* @param string|array $line
|
||||
* @return string
|
||||
*/
|
||||
protected function formatLine($line)
|
||||
{
|
||||
if (is_array($line)) {
|
||||
return implode(' ', array_map('trim', $line));
|
||||
}
|
||||
|
||||
return trim(implode(' ', array_map('trim', preg_split('/\\r\\n|\\r|\\n/', $line))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the "call to action" button.
|
||||
*
|
||||
* @param string $text
|
||||
* @param string $url
|
||||
* @return $this
|
||||
*/
|
||||
public function action($text, $url)
|
||||
{
|
||||
$this->actionText = $text;
|
||||
$this->actionUrl = $url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array representation of the message.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return [
|
||||
'level' => $this->level,
|
||||
'subject' => $this->subject,
|
||||
'greeting' => $this->greeting,
|
||||
'salutation' => $this->salutation,
|
||||
'introLines' => $this->introLines,
|
||||
'outroLines' => $this->outroLines,
|
||||
'actionText' => $this->actionText,
|
||||
'actionUrl' => $this->actionUrl,
|
||||
];
|
||||
}
|
||||
}
|
||||
241
vendor/laravel/framework/src/Illuminate/Notifications/Messages/SlackAttachment.php
vendored
Normal file
241
vendor/laravel/framework/src/Illuminate/Notifications/Messages/SlackAttachment.php
vendored
Normal file
@@ -0,0 +1,241 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Messages;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class SlackAttachment
|
||||
{
|
||||
/**
|
||||
* The attachment's title.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $title;
|
||||
|
||||
/**
|
||||
* The attachment's URL.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* The attachment's text content.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $content;
|
||||
|
||||
/**
|
||||
* A plain-text summary of the attachment.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $fallback;
|
||||
|
||||
/**
|
||||
* The attachment's color.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $color;
|
||||
|
||||
/**
|
||||
* The attachment's fields.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $fields;
|
||||
|
||||
/**
|
||||
* The fields containing markdown.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $markdown;
|
||||
|
||||
/**
|
||||
* The attachment's image url.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $imageUrl;
|
||||
|
||||
/**
|
||||
* The attachment's footer.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $footer;
|
||||
|
||||
/**
|
||||
* The attachment's footer icon.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $footerIcon;
|
||||
|
||||
/**
|
||||
* The attachment's timestamp.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timestamp;
|
||||
|
||||
/**
|
||||
* Set the title of the attachment.
|
||||
*
|
||||
* @param string $title
|
||||
* @param string $url
|
||||
* @return $this
|
||||
*/
|
||||
public function title($title, $url = null)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->url = $url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the content (text) of the attachment.
|
||||
*
|
||||
* @param string $content
|
||||
* @return $this
|
||||
*/
|
||||
public function content($content)
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A plain-text summary of the attachment.
|
||||
*
|
||||
* @param string $fallback
|
||||
* @return $this
|
||||
*/
|
||||
public function fallback($fallback)
|
||||
{
|
||||
$this->fallback = $fallback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the color of the attachment.
|
||||
*
|
||||
* @param string $color
|
||||
* @return $this
|
||||
*/
|
||||
public function color($color)
|
||||
{
|
||||
$this->color = $color;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a field to the attachment.
|
||||
*
|
||||
* @param \Closure|string $title
|
||||
* @param string $content
|
||||
* @return $this
|
||||
*/
|
||||
public function field($title, $content = '')
|
||||
{
|
||||
if (is_callable($title)) {
|
||||
$callback = $title;
|
||||
|
||||
$callback($attachmentField = new SlackAttachmentField);
|
||||
|
||||
$this->fields[] = $attachmentField;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->fields[$title] = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the fields of the attachment.
|
||||
*
|
||||
* @param array $fields
|
||||
* @return $this
|
||||
*/
|
||||
public function fields(array $fields)
|
||||
{
|
||||
$this->fields = $fields;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the fields containing markdown.
|
||||
*
|
||||
* @param array $fields
|
||||
* @return $this
|
||||
*/
|
||||
public function markdown(array $fields)
|
||||
{
|
||||
$this->markdown = $fields;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the image URL.
|
||||
*
|
||||
* @param string $url
|
||||
* @return $this
|
||||
*/
|
||||
public function image($url)
|
||||
{
|
||||
$this->imageUrl = $url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the footer content.
|
||||
*
|
||||
* @param string $footer
|
||||
* @return $this
|
||||
*/
|
||||
public function footer($footer)
|
||||
{
|
||||
$this->footer = $footer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the footer icon.
|
||||
*
|
||||
* @param string $icon
|
||||
* @return $this
|
||||
*/
|
||||
public function footerIcon($icon)
|
||||
{
|
||||
$this->footerIcon = $icon;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the timestamp.
|
||||
*
|
||||
* @param Carbon $timestamp
|
||||
* @return $this
|
||||
*/
|
||||
public function timestamp(Carbon $timestamp)
|
||||
{
|
||||
$this->timestamp = $timestamp->getTimestamp();
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
79
vendor/laravel/framework/src/Illuminate/Notifications/Messages/SlackAttachmentField.php
vendored
Normal file
79
vendor/laravel/framework/src/Illuminate/Notifications/Messages/SlackAttachmentField.php
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Messages;
|
||||
|
||||
class SlackAttachmentField
|
||||
{
|
||||
/**
|
||||
* The title field of the attachment field.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $title;
|
||||
|
||||
/**
|
||||
* The content of the attachment field.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $content;
|
||||
|
||||
/**
|
||||
* Whether the content is short.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $short = true;
|
||||
|
||||
/**
|
||||
* Set the title of the field.
|
||||
*
|
||||
* @param string $title
|
||||
* @return $this
|
||||
*/
|
||||
public function title($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the content of the field.
|
||||
*
|
||||
* @param string $content
|
||||
* @return $this
|
||||
*/
|
||||
public function content($content)
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that the content should not be displayed side-by-side with other fields.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function long()
|
||||
{
|
||||
$this->short = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the attachment field.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return [
|
||||
'title' => $this->title,
|
||||
'value' => $this->content,
|
||||
'short' => $this->short,
|
||||
];
|
||||
}
|
||||
}
|
||||
221
vendor/laravel/framework/src/Illuminate/Notifications/Messages/SlackMessage.php
vendored
Normal file
221
vendor/laravel/framework/src/Illuminate/Notifications/Messages/SlackMessage.php
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Messages;
|
||||
|
||||
use Closure;
|
||||
|
||||
class SlackMessage
|
||||
{
|
||||
/**
|
||||
* The "level" of the notification (info, success, warning, error).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $level = 'info';
|
||||
|
||||
/**
|
||||
* The username to send the message from.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $username;
|
||||
|
||||
/**
|
||||
* The user emoji icon for the message.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $icon;
|
||||
|
||||
/**
|
||||
* The user image icon for the message.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $image;
|
||||
|
||||
/**
|
||||
* The channel to send the message on.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $channel;
|
||||
|
||||
/**
|
||||
* The text content of the message.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $content;
|
||||
|
||||
/**
|
||||
* Indicates if channel names and usernames should be linked.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $linkNames = 0;
|
||||
|
||||
/**
|
||||
* The message's attachments.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $attachments = [];
|
||||
|
||||
/**
|
||||
* Additional request options for the Guzzle HTTP client.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $http = [];
|
||||
|
||||
/**
|
||||
* Indicate that the notification gives information about a successful operation.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function success()
|
||||
{
|
||||
$this->level = 'success';
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the notification gives information about a warning.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function warning()
|
||||
{
|
||||
$this->level = 'warning';
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the notification gives information about an error.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function error()
|
||||
{
|
||||
$this->level = 'error';
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a custom username and optional emoji icon for the Slack message.
|
||||
*
|
||||
* @param string $username
|
||||
* @param string|null $icon
|
||||
* @return $this
|
||||
*/
|
||||
public function from($username, $icon = null)
|
||||
{
|
||||
$this->username = $username;
|
||||
|
||||
if (! is_null($icon)) {
|
||||
$this->icon = $icon;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a custom image icon the message should use.
|
||||
*
|
||||
* @param string $image
|
||||
* @return $this
|
||||
*/
|
||||
public function image($image)
|
||||
{
|
||||
$this->image = $image;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Slack channel the message should be sent to.
|
||||
*
|
||||
* @param string $channel
|
||||
* @return $this
|
||||
*/
|
||||
public function to($channel)
|
||||
{
|
||||
$this->channel = $channel;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the content of the Slack message.
|
||||
*
|
||||
* @param string $content
|
||||
* @return $this
|
||||
*/
|
||||
public function content($content)
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define an attachment for the message.
|
||||
*
|
||||
* @param \Closure $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function attachment(Closure $callback)
|
||||
{
|
||||
$this->attachments[] = $attachment = new SlackAttachment;
|
||||
|
||||
$callback($attachment);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color for the message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function color()
|
||||
{
|
||||
switch ($this->level) {
|
||||
case 'success':
|
||||
return 'good';
|
||||
case 'error':
|
||||
return 'danger';
|
||||
case 'warning':
|
||||
return 'warning';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find and link channel names and usernames.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function linkNames()
|
||||
{
|
||||
$this->linkNames = 1;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set additional request options for the Guzzle HTTP client.
|
||||
*
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function http(array $options)
|
||||
{
|
||||
$this->http = $options;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
8
vendor/laravel/framework/src/Illuminate/Notifications/Notifiable.php
vendored
Normal file
8
vendor/laravel/framework/src/Illuminate/Notifications/Notifiable.php
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications;
|
||||
|
||||
trait Notifiable
|
||||
{
|
||||
use HasDatabaseNotifications, RoutesNotifications;
|
||||
}
|
||||
27
vendor/laravel/framework/src/Illuminate/Notifications/Notification.php
vendored
Normal file
27
vendor/laravel/framework/src/Illuminate/Notifications/Notification.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Notification
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The unique identifier for the notification.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
181
vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php
vendored
Normal file
181
vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications;
|
||||
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Database\Eloquent\Collection as ModelCollection;
|
||||
|
||||
class NotificationSender
|
||||
{
|
||||
/**
|
||||
* The notification manager instance.
|
||||
*
|
||||
* @var \Illuminate\Notifications\ChannelManager
|
||||
*/
|
||||
protected $manager;
|
||||
|
||||
/**
|
||||
* The Bus dispatcher instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Bus\Dispatcher
|
||||
*/
|
||||
protected $bus;
|
||||
|
||||
/**
|
||||
* The event dispatcher.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Events\Dispatcher
|
||||
*/
|
||||
protected $events;
|
||||
|
||||
/**
|
||||
* Create a new notification sender instance.
|
||||
*
|
||||
* @param \Illuminate\Notifications\ChannelManager $manager
|
||||
* @param \Illuminate\Contracts\Bus\Dispatcher $bus
|
||||
* @param \Illuminate\Contracts\Events\Dispatcher $events
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($manager, $bus, $events)
|
||||
{
|
||||
$this->bus = $bus;
|
||||
$this->events = $events;
|
||||
$this->manager = $manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given notification to the given notifiable entities.
|
||||
*
|
||||
* @param \Illuminate\Support\Collection|array|mixed $notifiables
|
||||
* @param mixed $notification
|
||||
* @return void
|
||||
*/
|
||||
public function send($notifiables, $notification)
|
||||
{
|
||||
$notifiables = $this->formatNotifiables($notifiables);
|
||||
|
||||
if ($notification instanceof ShouldQueue) {
|
||||
return $this->queueNotification($notifiables, $notification);
|
||||
}
|
||||
|
||||
return $this->sendNow($notifiables, $notification);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given notification immediately.
|
||||
*
|
||||
* @param \Illuminate\Support\Collection|array|mixed $notifiables
|
||||
* @param mixed $notification
|
||||
* @param array $channels
|
||||
* @return void
|
||||
*/
|
||||
public function sendNow($notifiables, $notification, array $channels = null)
|
||||
{
|
||||
$notifiables = $this->formatNotifiables($notifiables);
|
||||
|
||||
$original = clone $notification;
|
||||
|
||||
foreach ($notifiables as $notifiable) {
|
||||
$notificationId = Uuid::uuid4()->toString();
|
||||
|
||||
if (empty($viaChannels = $channels ?: $notification->via($notifiable))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ((array) $viaChannels as $channel) {
|
||||
$this->sendToNotifiable($notifiable, $notificationId, clone $original, $channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given notification to the given notifiable via a channel.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @param string $id
|
||||
* @param mixed $notification
|
||||
* @param string $channel
|
||||
* @return void
|
||||
*/
|
||||
protected function sendToNotifiable($notifiable, $id, $notification, $channel)
|
||||
{
|
||||
if (! $notification->id) {
|
||||
$notification->id = $id;
|
||||
}
|
||||
|
||||
if (! $this->shouldSendNotification($notifiable, $notification, $channel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response = $this->manager->driver($channel)->send($notifiable, $notification);
|
||||
|
||||
$this->events->dispatch(
|
||||
new Events\NotificationSent($notifiable, $notification, $channel, $response)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the notification can be sent.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @param mixed $notification
|
||||
* @param string $channel
|
||||
* @return bool
|
||||
*/
|
||||
protected function shouldSendNotification($notifiable, $notification, $channel)
|
||||
{
|
||||
return $this->events->until(
|
||||
new Events\NotificationSending($notifiable, $notification, $channel)
|
||||
) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queue the given notification instances.
|
||||
*
|
||||
* @param mixed $notifiables
|
||||
* @param array[\Illuminate\Notifications\Channels\Notification] $notification
|
||||
* @return void
|
||||
*/
|
||||
protected function queueNotification($notifiables, $notification)
|
||||
{
|
||||
$notifiables = $this->formatNotifiables($notifiables);
|
||||
|
||||
$original = clone $notification;
|
||||
|
||||
foreach ($notifiables as $notifiable) {
|
||||
$notificationId = Uuid::uuid4()->toString();
|
||||
|
||||
foreach ($original->via($notifiable) as $channel) {
|
||||
$notification = clone $original;
|
||||
|
||||
$notification->id = $notificationId;
|
||||
|
||||
$this->bus->dispatch(
|
||||
(new SendQueuedNotifications($this->formatNotifiables($notifiable), $notification, [$channel]))
|
||||
->onConnection($notification->connection)
|
||||
->onQueue($notification->queue)
|
||||
->delay($notification->delay)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the notifiables into a Collection / array if necessary.
|
||||
*
|
||||
* @param mixed $notifiables
|
||||
* @return ModelCollection|array
|
||||
*/
|
||||
protected function formatNotifiables($notifiables)
|
||||
{
|
||||
if (! $notifiables instanceof Collection && ! is_array($notifiables)) {
|
||||
return $notifiables instanceof Model
|
||||
? new ModelCollection([$notifiables]) : [$notifiables];
|
||||
}
|
||||
|
||||
return $notifiables;
|
||||
}
|
||||
}
|
||||
46
vendor/laravel/framework/src/Illuminate/Notifications/NotificationServiceProvider.php
vendored
Normal file
46
vendor/laravel/framework/src/Illuminate/Notifications/NotificationServiceProvider.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Contracts\Notifications\Factory as FactoryContract;
|
||||
use Illuminate\Contracts\Notifications\Dispatcher as DispatcherContract;
|
||||
|
||||
class NotificationServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Boot the application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->loadViewsFrom(__DIR__.'/resources/views', 'notifications');
|
||||
|
||||
if ($this->app->runningInConsole()) {
|
||||
$this->publishes([
|
||||
__DIR__.'/resources/views' => $this->app->resourcePath('views/vendor/notifications'),
|
||||
], 'laravel-notifications');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->singleton(ChannelManager::class, function ($app) {
|
||||
return new ChannelManager($app);
|
||||
});
|
||||
|
||||
$this->app->alias(
|
||||
ChannelManager::class, DispatcherContract::class
|
||||
);
|
||||
|
||||
$this->app->alias(
|
||||
ChannelManager::class, FactoryContract::class
|
||||
);
|
||||
}
|
||||
}
|
||||
42
vendor/laravel/framework/src/Illuminate/Notifications/RoutesNotifications.php
vendored
Normal file
42
vendor/laravel/framework/src/Illuminate/Notifications/RoutesNotifications.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Contracts\Notifications\Dispatcher;
|
||||
|
||||
trait RoutesNotifications
|
||||
{
|
||||
/**
|
||||
* Send the given notification.
|
||||
*
|
||||
* @param mixed $instance
|
||||
* @return void
|
||||
*/
|
||||
public function notify($instance)
|
||||
{
|
||||
app(Dispatcher::class)->send($this, $instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification routing information for the given driver.
|
||||
*
|
||||
* @param string $driver
|
||||
* @return mixed
|
||||
*/
|
||||
public function routeNotificationFor($driver)
|
||||
{
|
||||
if (method_exists($this, $method = 'routeNotificationFor'.Str::studly($driver))) {
|
||||
return $this->{$method}();
|
||||
}
|
||||
|
||||
switch ($driver) {
|
||||
case 'database':
|
||||
return $this->notifications();
|
||||
case 'mail':
|
||||
return $this->email;
|
||||
case 'nexmo':
|
||||
return $this->phone_number;
|
||||
}
|
||||
}
|
||||
}
|
||||
69
vendor/laravel/framework/src/Illuminate/Notifications/SendQueuedNotifications.php
vendored
Normal file
69
vendor/laravel/framework/src/Illuminate/Notifications/SendQueuedNotifications.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class SendQueuedNotifications implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* The notifiable entities that should receive the notification.
|
||||
*
|
||||
* @var \Illuminate\Support\Collection
|
||||
*/
|
||||
public $notifiables;
|
||||
|
||||
/**
|
||||
* The notification to be sent.
|
||||
*
|
||||
* @var \Illuminate\Notifications\Notification
|
||||
*/
|
||||
public $notification;
|
||||
|
||||
/**
|
||||
* All of the channels to send the notification too.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $channels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param \Illuminate\Support\Collection $notifiables
|
||||
* @param \Illuminate\Notifications\Notification $notification
|
||||
* @param array $channels
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($notifiables, $notification, array $channels = null)
|
||||
{
|
||||
$this->channels = $channels;
|
||||
$this->notifiables = $notifiables;
|
||||
$this->notification = $notification;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the notifications.
|
||||
*
|
||||
* @param \Illuminate\Notifications\ChannelManager $manager
|
||||
* @return void
|
||||
*/
|
||||
public function handle(ChannelManager $manager)
|
||||
{
|
||||
$manager->sendNow($this->notifiables, $this->notification, $this->channels);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the display name for the queued job.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function displayName()
|
||||
{
|
||||
return get_class($this->notification);
|
||||
}
|
||||
}
|
||||
47
vendor/laravel/framework/src/Illuminate/Notifications/composer.json
vendored
Normal file
47
vendor/laravel/framework/src/Illuminate/Notifications/composer.json
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "illuminate/notifications",
|
||||
"description": "The Illuminate Notifications package.",
|
||||
"license": "MIT",
|
||||
"homepage": "https://laravel.com",
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel/framework/issues",
|
||||
"source": "https://github.com/laravel/framework"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylor@laravel.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.6.4",
|
||||
"illuminate/broadcasting": "5.4.*",
|
||||
"illuminate/bus": "5.4.*",
|
||||
"illuminate/container": "5.4.*",
|
||||
"illuminate/contracts": "5.4.*",
|
||||
"illuminate/filesystem": "5.4.*",
|
||||
"illuminate/mail": "5.4.*",
|
||||
"illuminate/queue": "5.4.*",
|
||||
"illuminate/support": "5.4.*",
|
||||
"ramsey/uuid": "~3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Notifications\\": ""
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.4-dev"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"guzzlehttp/guzzle": "Required to use the Slack transport (~6.0).",
|
||||
"illuminate/database": "Required to use the database transport (5.4.*).",
|
||||
"nexmo/client": "Required to use the Nexmo transport (~1.0)."
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
58
vendor/laravel/framework/src/Illuminate/Notifications/resources/views/email.blade.php
vendored
Normal file
58
vendor/laravel/framework/src/Illuminate/Notifications/resources/views/email.blade.php
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
@component('mail::message')
|
||||
{{-- Greeting --}}
|
||||
@if (! empty($greeting))
|
||||
# {{ $greeting }}
|
||||
@else
|
||||
@if ($level == 'error')
|
||||
# Whoops!
|
||||
@else
|
||||
# Hello!
|
||||
@endif
|
||||
@endif
|
||||
|
||||
{{-- Intro Lines --}}
|
||||
@foreach ($introLines as $line)
|
||||
{{ $line }}
|
||||
|
||||
@endforeach
|
||||
|
||||
{{-- Action Button --}}
|
||||
@isset($actionText)
|
||||
<?php
|
||||
switch ($level) {
|
||||
case 'success':
|
||||
$color = 'green';
|
||||
break;
|
||||
case 'error':
|
||||
$color = 'red';
|
||||
break;
|
||||
default:
|
||||
$color = 'blue';
|
||||
}
|
||||
?>
|
||||
@component('mail::button', ['url' => $actionUrl, 'color' => $color])
|
||||
{{ $actionText }}
|
||||
@endcomponent
|
||||
@endisset
|
||||
|
||||
{{-- Outro Lines --}}
|
||||
@foreach ($outroLines as $line)
|
||||
{{ $line }}
|
||||
|
||||
@endforeach
|
||||
|
||||
{{-- Salutation --}}
|
||||
@if (! empty($salutation))
|
||||
{{ $salutation }}
|
||||
@else
|
||||
Regards,<br>{{ config('app.name') }}
|
||||
@endif
|
||||
|
||||
{{-- Subcopy --}}
|
||||
@isset($actionText)
|
||||
@component('mail::subcopy')
|
||||
If you’re having trouble clicking the "{{ $actionText }}" button, copy and paste the URL below
|
||||
into your web browser: [{{ $actionUrl }}]({{ $actionUrl }})
|
||||
@endcomponent
|
||||
@endisset
|
||||
@endcomponent
|
||||
Reference in New Issue
Block a user