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:
36
ci4/app/Entities/Chat/ChatUserEntity.php
Normal file
36
ci4/app/Entities/Chat/ChatUserEntity.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities\Chat;
|
||||
|
||||
use App\Entities\Usuarios\UserEntity;
|
||||
use App\Models\Chat\ChatModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use CodeIgniter\Entity\Entity;
|
||||
|
||||
class ChatUserEntity extends Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"user_id" => null,
|
||||
"chat_id" => null,
|
||||
];
|
||||
|
||||
|
||||
protected $casts = [
|
||||
"user_id" => "integer",
|
||||
"chat_id" => "integer",
|
||||
];
|
||||
|
||||
public function chat() : ?ChatEntity
|
||||
{
|
||||
$m = model(ChatModel::class);
|
||||
return $m->find($this->attributes['chat_id']);
|
||||
|
||||
}
|
||||
public function user() : ?UserEntity
|
||||
{
|
||||
$m = model(UserModel::class);
|
||||
return $m->find($this->attributes['user_id'])->withAvatar();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user