问题描述
我有一个名为attributes
的json
列类型的数据库模型.此列将包含模型的其他详细信息.
I have a database model with json
column type called attributes
. This column will contain additional details of the model.
例如:attributes : {'desc' : 'test', 'width' : '500'}
.
我想在Laravel管理资源中的html字段中的attributes
列中显示单个属性(desc
& width
).
I would like to display individual attribute (desc
& width
) in attributes
column as a html field in Laravel admin resource.
我检查了受支持的字段类型,但没有似乎不支持.
I checked supported field types and doesn't seem supports.
有人建议我该怎么做吗?
Any suggestions how I can do this?
推荐答案
我不确定这是否是建议的答案,但我已经找到一种适合您的方法.
I'm not sure if it's the recommended answer but i've found a way that should work for you.
使用口才突变体:口才突变体
然后,定义一个getDescAttribute
和setDescAttribute
并将其像模型中的属性一样以新星的形式传递给它,
Then you define a getDescAttribute
and a setDescAttribute
and pass it in nova like a property on the model like so:
Text::make('Desc', 'desc')
希望这会有所帮助.
这篇关于Laravel Nova-将数据库json列映射到字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!