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:
60
ci4/app/Entities/Chat/ChatDepartmentUserEntity.php
Normal file
60
ci4/app/Entities/Chat/ChatDepartmentUserEntity.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities\Chat;
|
||||
|
||||
use App\Entities\Facturas\FacturaEntity;
|
||||
use App\Entities\Pedidos\PedidoEntity;
|
||||
use App\Entities\Presupuestos\PresupuestoEntity;
|
||||
use App\Entities\Usuarios\UserEntity;
|
||||
use App\Models\Chat\ChatDeparmentModel;
|
||||
use App\Models\Pedidos\PedidoModel;
|
||||
use App\Models\Presupuestos\PresupuestoModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use CodeIgniter\Entity\Entity;
|
||||
|
||||
class ChatDepartmentUserEntity extends Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"chat_department_id" => null,
|
||||
"user_id" => null,
|
||||
"pedido_id" => null,
|
||||
"factura_id" => null,
|
||||
"presupuesto_id" => null,
|
||||
];
|
||||
|
||||
|
||||
protected $casts = [
|
||||
"chat_department_id" => "integer",
|
||||
"user_id" => "integer",
|
||||
"pedido_id" => "?integer",
|
||||
"factura_id" => "?integer",
|
||||
"presupuesto_id" => "?integer",
|
||||
];
|
||||
|
||||
public function user() : ?UserEntity
|
||||
{
|
||||
$m = model(UserModel::class);
|
||||
return $m->find($this->attributes['user_id']);
|
||||
}
|
||||
public function department() : ?ChatDepartmentEntity
|
||||
{
|
||||
$m = model(ChatDeparmentModel::class);
|
||||
return $m->find($this->attributes['chat_department_id']);
|
||||
}
|
||||
public function presupuesto() : ?PresupuestoEntity
|
||||
{
|
||||
$m = model(PresupuestoModel::class);
|
||||
return $m->find($this->attributes['presupuesto_id']);
|
||||
}
|
||||
public function pedido() : ?PedidoEntity
|
||||
{
|
||||
$m = model(PedidoModel::class);
|
||||
return $m->find($this->attributes['pedido_id']);
|
||||
}
|
||||
public function factura() : ?FacturaEntity
|
||||
{
|
||||
$m = model(FacturaEntity::class);
|
||||
return $m->find($this->attributes['factura_id']);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user