pdv.backend/app/Http/Traits/HasDatabaseNotifications.php
Moisés de Jesús Cortés Castellanos dfb1fbf1e9
ADD: Notificaciones en tiempo real (#3)
* ADD: Notificaciones
* ADD: Usuarios conectados en tiempo real
2024-12-27 12:10:56 -06:00

40 lines
885 B
PHP

<?php namespace App\Http\Traits;
use App\Models\Notification;
/**
* Notificaciones de base de datos
*
* @author Moisés Cortés C. <moises.cortes@notsoweb.com>
*/
trait HasDatabaseNotifications
{
/**
* Get the entity's notifications.
*/
public function notifications()
{
return $this->morphMany(Notification::class, 'notifiable')->with('user:id,name,paternal,maternal,profile_photo_path')->latest();
}
/**
* Get the entity's read notifications.
*
* @return \Illuminate\Database\Query\Builder
*/
public function readNotifications()
{
return $this->notifications()->read();
}
/**
* Get the entity's unread notifications.
*
* @return \Illuminate\Database\Query\Builder
*/
public function unreadNotifications()
{
return $this->notifications()->unread();
}
}