mercredi 18 mai 2022

Validation if the value exists else no validation

So, this is what i've tried already.

if ($request->get('websiteSchool') !== 'null' || $request->get('nextcontactSchool') !== 'null') {
                $this->validate($request, [
                    'websiteSchool' => 'url',
                    'nextcontactSchool' => 'digits_between:7,10'
                ]);
            } else {
                $this->validate($request, [
                    'websiteSchool' => 'nullable',
                    'nextcontactSchool' => 'nullable'
                ]);
            }

I did this in a controller once i figured that i can't properly make use of a rule. But the problem here is that, I cant seem to pass the empty data to the database and everytime that i do that, i get a error message.

Can you please help me out?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/zU1tWhn
via IFTTT

Aucun commentaire:

Enregistrer un commentaire