82 lines
1.9 KiB
PHP
82 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace Modules\Project\Notifications;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Notifications\Messages\BroadcastMessage;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class NewProjectAssignedNotification extends Notification
|
|
{
|
|
use Queueable;
|
|
|
|
/**
|
|
* Create a new notification instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct($project)
|
|
{
|
|
$this->project = $project;
|
|
}
|
|
|
|
/**
|
|
* Get the notification's delivery channels.
|
|
*
|
|
* @param mixed $notifiable
|
|
* @return array
|
|
*/
|
|
public function via($notifiable)
|
|
{
|
|
$channels = ['database'];
|
|
if (isPusherEnabled()) {
|
|
$channels[] = 'broadcast';
|
|
}
|
|
|
|
return $channels;
|
|
}
|
|
|
|
/**
|
|
* 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', 'https://laravel.com')
|
|
->line('Thank you for using our application!');
|
|
}
|
|
|
|
/**
|
|
* Get the array representation of the notification.
|
|
*
|
|
* @param mixed $notifiable
|
|
* @return array
|
|
*/
|
|
public function toArray($notifiable)
|
|
{
|
|
return [
|
|
'project_id' => $this->project->id,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get the broadcastable representation of the notification.
|
|
*
|
|
* @param mixed $notifiable
|
|
* @return BroadcastMessage
|
|
*/
|
|
public function toBroadcast($notifiable)
|
|
{
|
|
return new BroadcastMessage([
|
|
'title' => $this->project->title,
|
|
'body' => $this->project->body,
|
|
'link' => $this->project->link,
|
|
]);
|
|
}
|
|
}
|