Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
向laravel中的请求数组添加浮点值_Laravel - Fatal编程技术网

向laravel中的请求数组添加浮点值

向laravel中的请求数组添加浮点值,laravel,Laravel,我正在将此(float)str_replace(“,”,“$orders['grandtotal]”)添加到我的存储函数中,但我遇到了问题,解析错误:语法错误,意外的“=>”(T_双箭头),应为“,”或“” 这是我的商店功能 $orders = Orders::create($request->only( 'user_id', 'status_id', 'currency_id', 'company_id',

我正在将此(float)str_replace(“,”,“$orders['grandtotal]”)添加到我的存储函数中,但我遇到了问题,解析错误:语法错误,意外的“=>”(T_双箭头),应为“,”或“”

这是我的商店功能

 $orders = Orders::create($request->only(
        'user_id',
        'status_id',
        'currency_id',
        'company_id',
        'purchase_no',
        'notes',
        'delivery_date',
        'grandtotal' =>(float) str_replace(',', '', $orders['grandtotal']),
        'publish'
    ));

提前非常感谢

试试这段代码

 $data = $request->only(
    'user_id',
    'status_id',
    'currency_id',
    'company_id',
    'purchase_no',
    'notes',
    'delivery_date',
    'publish'
);
$data['grandtotal'] = (float) str_replace(',', '', $request->grandtotal);
$orders = Orders::create($data);