1$input = $request->only('account'); // dont use all(), ever
2
3$rules = [
4 'account' => 'required'
5];
6
7if (filter_var($input['account'], FILTER_VALIDATE_EMAIL)) {
8
9 $rules['account'] .= '|exists:users,email';
10
11} else {
12
13 $rules['account'] .= '|exists:users,username';
14
15}
16
17$messages = [
18 'account.required' => 'Enter username or email to login.',
19];
20
21$validator = Validator::make($input, $rules, $messages);