'array', ]; public $timestamps = false; static public $enums = [ 'type' => [ '' => 0, '仓储费' => 1, '快递费-合计' => 2, '入库费-合计' => 3, '出库费-合计' => 4, '物流费' => 5, '包材费' => 6, '加工费' => 7, '杂项费' => 8, '卸货费' => 9, '总费用' => 10, '理赔费' => 11, ], ]; function __construct(array $attributes = []) { foreach (self::$enums as &$enum) { $enum=$enum+array_flip($enum); } parent::__construct($attributes); } public function getTypeAttribute($value) { if (!$value) return ''; return self::$enums['type'][$value]; } public function setTypeAttribute($value) { if (!$value) return 0; $this->attributes['type'] = self::$enums['type'][$value]; } public function ownerBillReport(): BelongsTo { return $this->belongsTo(OwnerBillReport::class); } public function owner(): BelongsTo { return $this->belongsTo(Owner::class); } }