【发布时间】:2018-07-07 04:22:57
【问题描述】:
我正在尝试在 laravel 的 select 语句中添加数组, 这是示例数据,请查看以下片段,
$message =["messages"=>[
["attachment"=>
["type"=>"template","payload"=>
["template_type"=>"list","top_element_style"=>"large","elements"=>
[
["title"=>"test","image_url"=> "https://cdn-images-1.medium.com/max/375/0*sepg7sXXe3zcmGvZ.png","subtitle"=>"Soft white cotton t-shirt is back in style","buttons" =>
[
["type"=>"web_url","url"=>"https://petersapparel.parseapp.com/buy_item?item_id=101","title"=>"buy item"]
]
]
,
["title"=>"test","image_url"=> "https://cdn-images-1.medium.com/max/375/0*sepg7sXXe3zcmGvZ.png","subtitle"=>"Soft white cotton t-shirt is back in style","buttons" =>
[
["type"=>"web_url","url"=>"https://petersapparel.parseapp.com/buy_item?item_id=101","title"=>"buy item"]]
]
]
]
]
]
]
];
当我从 laravel 的数据库中提取时,我只能做直到字幕,我不能做按钮部分
["type"=>"web_url","url"=>"https://petersapparel.parseapp.com/buy_item?item_id=101","title"=>"buy item"]
,这是我的尝试,
$message =["messages"=>[
["attachment"=>
["type"=>"template","payload"=>
["template_type"=>"list","top_element_style"=>"large","elements"=>
[
Fabric::orderBy('id', 'DESC')->where('title', 'LIKE', "%$search_term%")
->select('title','postdate as image_url',"company_name as subtitle"
)->get()
]
]
]
]
]
];
我为每个按钮数组字段都有另一个字段,不知道如何在 select 语句中添加。任何帮助将不胜感激。
【问题讨论】: