vendredi 24 avril 2020

Dynamic If else statement, value for condition is from database

is there a way to make this if else condition:

$searchUserTypeName = UserType::findOrFail(1);

if ($searchUserTypeName->name == "Captain" || $searchUserTypeName->name == "Member") {
  echo "This is Captain or Member"
} else if ($searchUserTypeName->name == "Mentor" || $searchUserTypeName->name == "Mentee") {
  echo "This is Mentor or Mentee"
}

to dynamic?

The value Captain, Member, Mentor and Mentee is from a mysql table

hope you can help

thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire