本文整理汇总了PHP中App\Repositories\UserRepository::isUniqueEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRepository::isUniqueEmail方法的具体用法?PHP UserRepository::isUniqueEmail怎么用?PHP UserRepository::isUniqueEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Repositories\UserRepository
的用法示例。
在下文中一共展示了UserRepository::isUniqueEmail方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rules
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return ['username' => ['type' => 'username', 'error' => '{auth.register.error.username.invalid}', 'required' => '{auth.register.error.username.required}', 'filters' => ['string.trim' => true], 'success' => function ($username, ValidationError $validationError, ValidationManager $validationManager) {
if (!$this->userRepository->isUniqueUsername($username)) {
$validationError->setError('{auth.register.error.username.not_unique}');
}
}], 'email' => ['type' => 'email', 'error' => '{auth.register.error.email.invalid}', 'required' => '{auth.register.error.email.required}', 'filters' => ['string.trim' => true], 'success' => function ($email, ValidationError $validationError, ValidationManager $validationManager) {
if (!$this->userRepository->isUniqueEmail($email)) {
$validationError->setError('{auth.register.error.email.not_unique}');
}
}], 'password' => ['type' => 'password', 'error' => '{auth.register.error.password.invalid}', 'required' => '{auth.register.error.password.required}'], 'password_confirmation' => ['type' => 'string', 'error' => '{auth.register.error.password_confirmation.not_match}', 'success' => function ($passwordConfirmation, ValidationError $validationError, ValidationManager $validationManager) {
$password = $validationManager->getData('password');
if (empty($password) || !$validationManager->getValidationResult()->isValid('password')) {
return;
}
if (empty($passwordConfirmation)) {
$validationError->setError('{auth.register.error.password_confirmation.required}');
} else {
if ($validationManager->getData('password') !== $passwordConfirmation) {
$validationError->setError('{auth.register.error.password_confirmation.not_match}');
}
}
}]];
}