I have a form, which displays a Google reCaptcha if no user logged in. If there's a user logged in, no reCaptcha is shown.
OK.
But When I validate those POST parameters I need to check if the user is logged in or not, to validate reCaptcha or not. Like this:
//Check if logged in user
if (Auth::check()) {
$request->validate([
'category' => 'bail|required|numeric',
'title' => 'bail|required|max:160|banned_words',
'price' => 'numeric',
'description' => 'bail|required|banned_words',
'contact_name' => 'bail|required|max:100',
'contact_email' => 'bail|required|email|max:140',
'phone' => 'bail|required|max:20',
'ad_region' => 'bail|required|numeric',
"agree" => 'bail|required',
]);
} else {
$request->validate([
'category' => 'bail|required|numeric',
'title' => 'bail|required|max:160|banned_words',
'price' => 'numeric',
'description' => 'bail|required|banned_words',
'contact_name' => 'bail|required|max:100',
'contact_email' => 'bail|required|email|max:140',
'phone' => 'bail|required|max:20',
'ad_region' => 'bail|required|numeric',
"agree" => 'bail|required',
'g-recaptcha-response' => 'recaptcha', //Recaptcha Google Check
]);
}
So, is there a more pretty inline solution?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3ai59Na
via IFTTT
Aucun commentaire:
Enregistrer un commentaire