优化部分代码,增加微信公众号模板
This commit is contained in:
@@ -96,7 +96,17 @@ class AdminService extends BaseService
|
||||
{
|
||||
$params['ip_table'] = json_encode([]);
|
||||
$params['password'] = password_hash($params['password'], PASSWORD_DEFAULT);
|
||||
$existsUser = $this->model::where('phone', $params['phone'])->whereOr('email', $params['email'])->exists();
|
||||
// 手机号或邮箱任一重复都拒绝,且必须排除软删记录(deleted_at=0)。
|
||||
// 原写法 whereOr('email',...) 是 Laravel 动态 where 的空操作(等于只按 phone 判断且不排软删),
|
||||
// 这里用闭包 orWhere 正确表达「phone OR email」;email 为空时不参与判重,避免误伤空邮箱账号
|
||||
$email = $params['email'] ?? '';
|
||||
$existsUser = $this->model::where('deleted_at', 0)
|
||||
->where(function ($q) use ($params, $email) {
|
||||
$q->where('phone', $params['phone']);
|
||||
if ($email !== '') {
|
||||
$q->orWhere('email', $email);
|
||||
}
|
||||
})->exists();
|
||||
if ($existsUser) {
|
||||
$this->utils->errorThrow('账号或邮箱已存在');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user