You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
717 B
PHP
29 lines
717 B
PHP
<?php namespace App\Validators;
|
|
|
|
use App\Models\User;
|
|
|
|
class Validation {
|
|
|
|
public function validateIsUserDuplicatePhone($attribute, $value, $parameters, $validator)
|
|
{
|
|
$phone = removeHyphen(filterPhone($value));
|
|
$type = 'Front';
|
|
$validatorData = $validator->getData();
|
|
|
|
if(isset($validatorData['type'])) $type = $validatorData['type'];
|
|
|
|
$user = User::query()->whereCrypt('phone', $phone)->where('type', $type);
|
|
|
|
// uid 가 있다면 자신은 제외
|
|
if(isset($validatorData['uid'])) {
|
|
$uid = $validatorData['uid'];
|
|
$user->where('uid', '<>', $uid);
|
|
}
|
|
$count = $user->count();
|
|
|
|
return $count == 0;
|
|
}
|
|
|
|
|
|
}
|