Created
August 11, 2021 23:36
-
-
Save patrickcurl/4c878821fadf0a8a3cb785679e02dafe to your computer and use it in GitHub Desktop.
Laravel Breeze Tutorial LoginRequest.php Changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class LoginRequest extends FormRequest | |
{ | |
protected $loginField; | |
protected $loginValue; | |
/** | |
* Prepare the data for validation. | |
* | |
* @return void | |
*/ | |
protected function prepareForValidation() | |
{ | |
$this->loginField = filter_var($this->input('login'), | |
FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; | |
$this->loginValue = $this->input('login'); | |
$this->merge([$this->loginField => $this->loginValue]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment