57 lines
1.5 KiB
PHP
57 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Modules\ProfessionalProject\Notifications;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Notifications\Messages\BroadcastMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
use Modules\ProfessionalProject\Entities\PpTask;
|
|
|
|
class NewTaskAssignedNotification extends Notification
|
|
{
|
|
use Queueable;
|
|
|
|
protected $task;
|
|
protected $actorName;
|
|
|
|
public function __construct(PpTask $task, $actorName)
|
|
{
|
|
$this->task = $task;
|
|
$this->actorName = $actorName;
|
|
}
|
|
|
|
public function via($notifiable)
|
|
{
|
|
$channels = ['database'];
|
|
if (function_exists('isPusherEnabled') && isPusherEnabled()) {
|
|
$channels[] = 'broadcast';
|
|
}
|
|
|
|
return $channels;
|
|
}
|
|
|
|
public function toArray($notifiable)
|
|
{
|
|
return [
|
|
'pp_task_id' => $this->task->id,
|
|
'pp_project_id' => $this->task->project_id,
|
|
'actor_name' => $this->actorName,
|
|
];
|
|
}
|
|
|
|
public function toBroadcast($notifiable)
|
|
{
|
|
return new BroadcastMessage([
|
|
'title' => __('professionalproject::lang.task_assigned_title'),
|
|
'body' => __(
|
|
'professionalproject::lang.new_task_assigned_notification',
|
|
[
|
|
'created_by' => $this->actorName,
|
|
'subject' => $this->task->title,
|
|
]
|
|
),
|
|
'link' => action([\Modules\ProfessionalProject\Http\Controllers\ProjectController::class, 'show'], ['id' => $this->task->project_id]).'?tab=tasks',
|
|
]);
|
|
}
|
|
}
|