Aug 30, 2017
0
Level 1
FormRequest overriding
TL;DR - what is the right way to validate things in action if it's not for one input rule (I mean I can't use default Validator because I need to validate based on 2 Request params)?
For example,
//User can only upload Ad image or insert a 3rd party Ad Network Embed - but not both
if ($request->hasFile('file') && strlen($request->get('adnetwork_embed'))) {
return redirect(route('ads.create'))
->withErrors(['You can only have either the Ad Image or 3rd party Ad Network (not
both) in one ad'])
->withInput();
}
I have store action on my Controller. Originally I've had validation in Controller class, but that's not the right way to do it so I've made StoreAdRequest where I've defined basic rules
but don't know how to define (the right way) those complicated rules. How to do it?
Please or to participate in this conversation.