mardi 26 juin 2018

Refactoring controllers - Form Validation Request with conditionals

I have a submit method which is pretty big, and I need to scale it out. I'm going to put the validation logic into a request class.

How can I replicate my conditionals as an if statement.

For example this rule checks if the user has accepted the terms before submitting

1 is the no value

if(!($request->has('terms') && $request->terms == 1)){
            return redirect()->back()->withFlashDanger("Please accept terms and condition.");}

How would i write this in the rules method in my request class



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

Aucun commentaire:

Enregistrer un commentaire