id = $id; } /** * Determine if the validation rule passes. * * @param string $attribute * @param mixed $value * @return bool */ public function passes($attribute, $value) { $hashed = md5($value); $user = User::where('email_hash', $hashed); if (isset($this->id) && !empty($this->id)) { $user = $user->where('id', '!=', $this->id); } $user = $user->first(); if ($user === null) { return true; } return false; } /** * Get the validation error message. * * @return string */ public function message() { return trans('validation.unique', ['attribute' => 'email']); } }