arcos-backend/app/Http/Traits/HasDatabaseNotifications.php
Moisés de Jesús Cortés Castellanos fc1e5728a7
REFACTOR: Refactorizacion y documentacion (#4)
2024-12-28 13:51:57 -06:00

45 lines
1001 B
PHP

<?php namespace App\Http\Traits;
/**
* @copyright (c) 2024 Notsoweb Software (https://notsoweb.com) - All Rights Reserved
*/
use App\Models\Notification;
/**
* Notificaciones de base de datos
*
* @author Moisés Cortés C. <moises.cortes@notsoweb.com>
*
* @version 1.0.0
*/
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();
}
}