Files
Sistema-Educativo-Laravel/app/Support/Notifier.php
T
fernando 0273fbfddd feat: notificaciones en tiempo real para social (likes, comentarios, solicitudes)
- Notifier helper: guarda en BD + broadcast en un solo llamado
- AppNotification: notificación genérica para canal database
- FriendshipController: notifica al recibir solicitud y al aceptarla
- PostController: notifica al autor cuando le dan like o comentan (excepto en propio post)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-28 17:15:28 -06:00

26 lines
665 B
PHP

<?php
namespace App\Support;
use App\Events\NewNotification;
use App\Models\User;
use App\Notifications\AppNotification;
class Notifier
{
public static function send(
User $recipient,
string $title,
string $body = '',
string $icon = 'fa-bell',
string $color = 'primary',
?string $url = null,
): void {
// Persist in DB so it shows on page reload
$recipient->notify(new AppNotification($title, $body, $url, $icon, $color));
// Broadcast in real-time to the bell dropdown
broadcast(new NewNotification($recipient->id, $title, $body, $icon, $color, $url));
}
}