43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Events;
|
|
|
|
use App\Models\DepartmentPatient;
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
use Illuminate\Broadcasting\PrivateChannel;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class PatientDataChanged implements ShouldBroadcast
|
|
{
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
|
|
public function __construct(
|
|
public DepartmentPatient $patient,
|
|
public string $action
|
|
) {}
|
|
|
|
public function broadcastOn(): array
|
|
{
|
|
return [new PrivateChannel('headquarters')];
|
|
}
|
|
|
|
public function broadcastAs(): string
|
|
{
|
|
return 'patient.changed';
|
|
}
|
|
|
|
public function broadcastWith(): array
|
|
{
|
|
return [
|
|
'id' => $this->patient->department_patient_id,
|
|
'department_id' => $this->patient->rf_department_id,
|
|
'full_name' => $this->patient->full_name,
|
|
'action' => $this->action,
|
|
'is_current' => $this->patient->is_current,
|
|
'changed_at' => now()->toISOString(),
|
|
];
|
|
}
|
|
}
|