lundi 22 novembre 2021

Too many if else statement Laravel

I have a query where user can have 3 option value where they can either just choose one on each option or 2 of either option of even 3 of the option. However, when creating the if else statement in the controller, the if else comes up until 7 statements. Any ideas how to reduce the if else statement. each if else statement gives different input inside, as an example

if (1 !="" && 2 =="" && 3==""){

}elseif(1 =="" && 2 !="" && 3==""){

}elseif(1 =="" && 2 =="" && 3!=""){

}elseif(1 !="" && 2 !="" && 3 ==""){

}elseif(1 !="" && 2 =="" && 3 !=""){

}elseif(1 =="" && 2 !="" && 3 !=""){

}elseif(1 !="" && 2 !="" && 3 !=""){

}else{}

Aucun commentaire:

Enregistrer un commentaire