message refactor

This commit is contained in:
amazuecos
2025-03-24 08:12:06 +01:00
parent 61af547135
commit c0d54e28b7
26 changed files with 994 additions and 677 deletions

View File

@ -1,6 +1,8 @@
<?php
namespace App\Entities\Usuarios;
use App\Entities\Chat\ChatNotificationEntity;
use App\Models\ChatNotification;
use CodeIgniter\Entity;
class UserEntity extends \CodeIgniter\Entity\Entity
@ -55,4 +57,20 @@ class UserEntity extends \CodeIgniter\Entity\Entity
{
return $this->getFullName();
}
public function withAvatar() : self
{
$users = auth()->getProvider();
$this->attributes["avatar"] = md5($users->findById($this->attributes['id'])->getEmail());
return $this;
}
/**
* Return an array of ChatNotificationEntities that belongs to the user
*
* @return array<ChatNotificationEntity>
*/
public function chatNotifications() : array
{
$m = model(ChatNotification::class);
return $m->where('user_id',$this->attributes['id'])->findAll() ?? [];
}
}