feat: header con mensajes y notificaciones en tiempo real
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class NewNotification implements ShouldBroadcastNow
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public function __construct(
|
||||
public int $userId,
|
||||
public string $title,
|
||||
public string $body,
|
||||
public string $icon = 'fa-bell',
|
||||
public string $color = 'primary',
|
||||
public ?string $url = null,
|
||||
) {}
|
||||
|
||||
public function broadcastOn(): array
|
||||
{
|
||||
return [new Channel('notifications.' . $this->userId)];
|
||||
}
|
||||
|
||||
public function broadcastWith(): array
|
||||
{
|
||||
return [
|
||||
'title' => $this->title,
|
||||
'body' => $this->body,
|
||||
'icon' => $this->icon,
|
||||
'color' => $this->color,
|
||||
'url' => $this->url,
|
||||
'time' => now()->format('H:i'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user