merge from main

This commit is contained in:
amazuecos
2024-12-15 19:49:33 +01:00
65 changed files with 2009 additions and 4007 deletions

View File

@ -25,6 +25,15 @@ class UserModel extends ShieldUserModel
];
}
const SORTABLE = [
0 => "t1.id",
1 => "t1.first_name",
2 => "t1.last_name",
3 => "t2.secret",
4 => "t3.nombre",
5 => "t1.last_active",
];
protected $returnType = UsersEntity::class;
protected $useSoftDeletes = true;
@ -36,6 +45,7 @@ class UserModel extends ShieldUserModel
protected $validationRules = [
"first_name" => "required|trim|max_length[150]",
"last_name" => "required|trim|max_length[150]",
"email" => "required|valid_email|max_length[150]",
'new_pwd' => 'permit_empty|min_length[8]',
'new_pwd_confirm' => 'permit_empty|required_with[new_pwd]|matches[new_pwd]',
"comments" => "permit_empty|trim|max_length[512]"
@ -59,9 +69,42 @@ class UserModel extends ShieldUserModel
'comments' => [
"max_length" => "Users.validation.last_name.max_length",
],
'email' => [
"required" => "Users.validation.email.required",
"valid_email" => "Users.validation.email.valid_email",
"max_length" => "Users.validation.email.max_length"
]
];
public function getResource($search = [])
{
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id as id, t1.first_name AS first_name, t1.last_name AS last_name,
t2.secret AS email, t1.last_active AS last_active, t3.nombre AS cliente"
);
$builder->join("auth_identities t2", "t1.id = t2.user_id", "left");
$builder->join("clientes t3", "t1.cliente_id = t3.id", "left");
$builder->where('t1.deleted_at', null)->groupBy("t1.id");
if (empty($search))
return $builder;
else {
$builder->groupStart();
foreach ($search as $col_search) {
$column = self::SORTABLE[$col_search[0]];
$value = $col_search[2];
$builder->where("LOWER(CONVERT($column USING utf8)) COLLATE utf8_general_ci LIKE", "%" . strtolower($value) . "%");
}
$builder->groupEnd();
return $builder;
}
}
public function getComerciales()
{