123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace App\Rules;
- use App\MicroApi\Services\UserService;
- use Illuminate\Contracts\Validation\Rule;
- class UniqueEmail implements Rule
- {
-
- protected $userService;
-
- public function __construct()
- {
- $this->userService = resolve('microUserService');
- }
-
- public function passes($attribute, $value)
- {
- return $this->userService->getByEmail($value) == null;
- }
-
- public function message()
- {
- return '该邮箱已经被注册,请使用其它邮箱';
- }
- }
|