【发布时间】:2017-08-25 16:32:24
【问题描述】:
我有表 settings 与列:
value - varchar 类型包含设置值,type - 枚举类型包含变量类型 "int", "string", "float"。如何使用type 列中的字符串将值转换为这种类型?
我正在尝试在我的模型中这样做,但它不起作用:
public function getValueAttribute($value){
return ($this->type)$value;
}
【问题讨论】:
-
考虑改用
settype()
标签: php laravel-5 typecast-operator