mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
implementado pestaña clientes en usuarios
This commit is contained in:
@ -16,9 +16,10 @@ class ClienteUsuariosModel extends ShieldUserModel
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.first_name",
|
||||
1 => "t1.last_name",
|
||||
2 => "t2.secret",
|
||||
0 => "t1.id",
|
||||
1 => "t1.first_name",
|
||||
2 => "t1.last_name",
|
||||
3 => "t2.secret",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["id", "first_name", "last_name", "email"];
|
||||
@ -83,6 +84,19 @@ class ClienteUsuariosModel extends ShieldUserModel
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function removeClienteFromUser($user_id = -1){
|
||||
|
||||
$this->db->table($this->table)->where('id', $user_id)->update(['cliente_id' => null]);
|
||||
}
|
||||
|
||||
|
||||
public function addUserToClient($user_id = -1, $cliente_id = -1){
|
||||
if($user_id < 1 || $cliente_id < 1){
|
||||
return;
|
||||
}
|
||||
$this->db->table($this->table)->where('id', $user_id)->update(['cliente_id' => $cliente_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
@ -100,15 +114,8 @@ class ClienteUsuariosModel extends ShieldUserModel
|
||||
);
|
||||
|
||||
$builder->join("auth_identities t2", "t1.id = t2.user_id", "left");
|
||||
$builder->where('t1.id', $cliente_id);
|
||||
$builder->where('t1.cliente_id', $cliente_id);
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.first_name", $search)
|
||||
->orLike("t1.last_name", $search)
|
||||
->orLike("t2.secret", $search)
|
||||
->groupEnd();
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user