【发布时间】:2022-01-18 04:51:08
【问题描述】:
protected $status = array(
'sale' => [
'background' => 'bg-info-light',
'color' => 'text-info'
],
'completed' => [
'background' => 'bg-success-light',
'color' => 'text-success'
],
);
我已经定义了数组,并且
$background = $this->code_status[$status]['background'];
$color = $this->code_status[$status]['color'];
return "<span class='fw-semibold d-inline-block py-1 px-3 rounded-pill " . $background . " " . $color . "'>$status</span>";
使用的是数据表,但我还有 20 个状态,并且必须为每个状态定义,如果继续写入 20 个数组,我的控制器会很长,我怎样才能更好地重写它?
【问题讨论】:
标签: arrays laravel database eloquent datatable