laravel语法错误,意外的“ foreach”(T_FOREACH),预期为“]”

时间:2019-07-02 14:09:31

标签: php json laravel-5

请帮助我, 我在Laravel项目上遇到问题。我想要“ foreach”作为“项目详细信息”。

'item_details' => [
                    [
                        'id'       => 'REQ00'.$pesanan->id,
                        'price'    => $standar_price,
                        'quantity' => 1,
                        'name'     => 'Product Name'
                    ],
                    foreach($extras as $extra){
                        [
                            'id'       => 'EXT'.$extra->id,
                            'price'    => ExtraCategory::where('id',$extra->extra_code)->first()->price,
                            'quantity' => 1,
                            'name'     => ExtraCategory::where('id',$extra->extra_code)->first()->title
                        ]
                    }
                ]

0 个答案:

没有答案