Archived
1
0
Fork 0

app/models/Data/User.php: adding findFirstByUsernameOrEmail()

This commit is contained in:
Henrik Hautakoski 2018-03-20 22:48:10 +01:00
parent ba39333e1a
commit cf92cfe37a

View file

@ -110,4 +110,18 @@ class User extends Model
$this->password = $password;
return $this;
}
/**
* Find the first user by Username or Email
*
* @param string $value
* @return User|bool
*/
static public function findFirstByUsernameOrEmail($value)
{
return self::findFirst([
"email = :v: OR username = :v:",
"bind" => [ 'v' => $value ]
]);
}
}