mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
message refactor
This commit is contained in:
42
ci4/app/Entities/Chat/ChatNotificationEntity.php
Normal file
42
ci4/app/Entities/Chat/ChatNotificationEntity.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?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();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user