mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
43 lines
955 B
PHP
43 lines
955 B
PHP
<?php
|
|
|
|
namespace App\Entities\Chat;
|
|
|
|
use App\Entities\Usuarios\UserEntity;
|
|
use App\Models\Chat\ChatMessageModel;
|
|
use App\Models\Usuarios\UserModel;
|
|
use CodeIgniter\Entity\Entity;
|
|
use CodeIgniter\HTTP\Message;
|
|
|
|
class ChatNotificationEntity extends Entity
|
|
{
|
|
protected $attributes = [
|
|
"id" => null,
|
|
"chat_message_id" => null,
|
|
"user_id" => null,
|
|
"viewed" => null,
|
|
];
|
|
|
|
|
|
protected $casts = [
|
|
"chat_message_id" => "integer",
|
|
"user_id" => "integer",
|
|
"viewed" => "boolean",
|
|
];
|
|
|
|
public function message() : ?ChatMessageEntity
|
|
{
|
|
$m = model(ChatMessageModel::class);
|
|
return $m->find($this->attributes['chat_message_id']);
|
|
}
|
|
public function user() : ?UserEntity
|
|
{
|
|
$m = model(UserModel::class);
|
|
return $m->find($this->attributes['user_id']);
|
|
}
|
|
public function chat() : ?ChatEntity
|
|
{
|
|
return $this->message()->chat();
|
|
}
|
|
|
|
}
|