Actualizacion automatica: 2024-05-07 21:16:26

This commit is contained in:
imnavajas
2024-05-07 21:16:39 +02:00
parent bdf605b26f
commit a38ebc012f
12 changed files with 100 additions and 255 deletions

View File

@ -2,9 +2,11 @@
namespace App\Models\Clientes;
class ClienteUsuariosModel extends \App\Models\BaseModel
use CodeIgniter\Shield\Models\UserModel as ShieldUserModel;
class ClienteUsuariosModel extends ShieldUserModel
{
protected $table = "auth_user";
protected $table = "users";
/**
* Whether primary key uses auto increment.
@ -16,11 +18,11 @@ class ClienteUsuariosModel extends \App\Models\BaseModel
const SORTABLE = [
0 => "t1.first_name",
1 => "t1.last_name",
2 => "t1.email",
2 => "t2.secret",
];
protected $allowedFields = ["id", "first_name", "last_name", "email"];
protected $returnType = "App\Entities\Usuarios\UserEntity";
protected $returnType = "App\Entities\Usuarios\UsersEntity";
protected $useTimestamps = true;
protected $useSoftDeletes = false;
@ -93,10 +95,12 @@ class ClienteUsuariosModel extends \App\Models\BaseModel
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id_user AS id, t1.first_name AS nombre, t1.last_name AS apellidos, t1.email AS email"
"t1.id AS id, t1.first_name AS nombre, t1.last_name AS apellidos,
t2.secret AS email"
);
$builder->where('t1.id_user', $cliente_id);
$builder->join("auth_identities t2", "t1.id = t2.user_id", "left");
$builder->where('t1.id', $cliente_id);
return empty($search)
? $builder
@ -104,7 +108,7 @@ class ClienteUsuariosModel extends \App\Models\BaseModel
->groupStart()
->like("t1.first_name", $search)
->orLike("t1.last_name", $search)
->orLike("t1.email", $search)
->orLike("t2.secret", $search)
->groupEnd();
}
}