mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-12-01 04:12:22 +03:00
The user model can validate usernames
This commit is contained in:
parent
f0992fd4f6
commit
f58d3b142b
1 changed files with 22 additions and 4 deletions
|
@ -417,4 +417,22 @@ class Users_model extends EA_Model {
|
|||
{
|
||||
// Users do not currently have any related resources.
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the username.
|
||||
*
|
||||
* @param string $username Username.
|
||||
* @param int|null $user_id Exclude user ID.
|
||||
*
|
||||
* @return bool Returns the validation result.
|
||||
*/
|
||||
public function validate_username(string $username, int $user_id = NULL): bool
|
||||
{
|
||||
if ( ! empty($user_id))
|
||||
{
|
||||
$this->db->where('id_users !=', $user_id);
|
||||
}
|
||||
|
||||
return $this->db->get_where('user_settings', ['username' => $username])->num_rows() === 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue