【发布时间】:2021-05-26 18:51:45
【问题描述】:
我喜欢将所有这些值都放在一个中心位置。例如,我可能有一个如下所示的枚举:
$mobies = [
'APPLE' => "Apple",
'SUM' => "Sumsung",
'LG' => "LG",
];
我想在我的视图/模板中使用:
迁移表
Schema::create('products', function (Blueprint $table) {
$table->id;
$table->enum('mobiles',['apple','sumsung','lg']);
...
});
config/enums.php
<?php
return [
'mobiles' => [
'APPLE' => "Apple",
'SUM' => "Sumsung",
'LG' => "LG",
];
];
index.blade.php
{{ config('enums.reportableTitle') }}
保存在数据库中时如何在刀片中显示。
【问题讨论】:
-
有人可以回答我的问题吗?