update notification

This commit is contained in:
Mathieu Lagace
2020-07-27 16:41:28 -04:00
parent c16d1e7e95
commit 2d64d6d422
28 changed files with 1167 additions and 47 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\BroadcastMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
@@ -13,6 +14,7 @@ class Alert extends Notification
protected $fromUser;
protected $myNotification;
private $myUrl;
/**
* Create a new notification instance.
@@ -34,7 +36,7 @@ class Alert extends Notification
*/
public function via($notifiable)
{
return ['database'];
return ['database','broadcast'];
}
/**
@@ -51,4 +53,18 @@ class Alert extends Notification
'url' => $this->myUrl,
];
}
public function toBroadcast($notifiable)
{
return new BroadcastMessage([
'from' => $this->fromUser,
'msg' => $this->myNotification,
'url' => $this->myUrl,
]);
}
public function broadcastType()
{
return 'notification.alert';
}
}

View File

@@ -0,0 +1,65 @@
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class ScheduleNotification extends Notification
{
use Queueable;
protected String $name;
protected String $msg;
protected String $url;
protected String $icon;
/**
* Create a new notification instance.
*
* @param String $name
* @param String $msg
* @param String $url
*/
public function __construct(String $name,String $msg,String $url)
{
$this->name = $name;
$this->msg = $msg;
$this->url = $url;
$this->icon = '<i class="far fa-calendar"></i>';
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['database','broadcast'];
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
'name' => $this->name,
'msg' => $this->msg,
'url' => $this->url,
'icon' => $this->icon
];
}
public function broadcastType()
{
return 'notification.schedule';
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class SystemNotification extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
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.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}