30 lines
934 B
PHP
30 lines
934 B
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Notifications\Notification;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
class customDocumentChannel
|
|
{
|
|
use Queueable;
|
|
|
|
public function send($notifiable, Notification $notification)
|
|
{
|
|
$data = $notification->toDatabase($notifiable);
|
|
$document_id = $data['workflow_document_id'];
|
|
unset($data['workflow_document_id']);
|
|
|
|
\App\Notification::where('notifiable_id', $notifiable->id)->where('workflow_document_id', $document_id)->whereNull('read_at')->update(['read_at'=>now()->format('Y-m-d H:i:s')]);
|
|
|
|
return $notifiable->routeNotificationFor('database')->create([
|
|
'id' => $notification->id,
|
|
'workflow_document_id'=> $document_id,
|
|
'notifiable_type' => $notifiable->user_id,
|
|
'type' => get_class($notification),
|
|
'data' => $data,
|
|
]);
|
|
}
|
|
}
|