[ 'required', 'email', function ($attribute, $value, $fail) { if ('sqlite' === config('database.default')) { $user = DB::table('users') ->whereRaw('email = "' . $value . '" COLLATE NOCASE') ->first(); } else { $user = DB::table('users') ->where('email', $value) ->first(); } if (!$user) { $fail(__('validation.custom.email.exists')); } }, ], 'password' => 'required|string', ]; } /** * Prepare the data for validation. * * @return void */ protected function prepareForValidation() { $this->merge([ 'email' => strtolower($this->email), ]); } }