最佳答案
Laravel has a <select>
form helper which takes as input a dictionary. I like to keep the values for all of these in a central place. For example, I might have an enum that looks like this:
$phoneTypes = [
'CELL' => "Cellular",
'HOME' => "Home",
'WORK' => "Work",
];
Which I want to use in both my view/template, and in the database:
Schema::create('customers', function (Blueprint $table) {
$table->increments('id');
$table->enum('pri_phone_type',array_keys($phoneTypes));
...
});