vendredi 1 décembre 2017

field validation to make dependency in laravel

I have 3 fields - type(hw/sw),hardware type(dropdown) and asset_request.'Type' field is dropdown hardware(1) and software(2).'hardware type' has phone(1),camera(2),others(3)

If I chosen hardware(1),hardware type field is mandary and asset_request field is not mandatory.

If I chosen software(0) only asset_request field is mandatory.

If I chosen type=hardware(1) and hardware type=others(3) asset_request field is mandatory. how to validate this in laravel

$this->validate($request,[
                'hardware_type' => 'required_without:asset_request',
                'asset_request' => 'required_without:hardware_type',
                 //want to check asset_request is required if hardware_type is 3 
            ],$messages);



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire