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-ErrorException:数组到字符串的转换_Laravel_Laravel 5 - Fatal编程技术网

Laravel-ErrorException:数组到字符串的转换

Laravel-ErrorException:数组到字符串的转换,laravel,laravel-5,Laravel,Laravel 5,在使用php artisan route:list时,我在Laravel的这段代码中遇到了一个问题 ErrorException : Array to string conversion at /var/www/html/app/Http/Controllers/Merchant/CountryAreaController.php:312 308| } 309| } 310| if (!empty($

在使用php artisan route:list时,我在Laravel的这段代码中遇到了一个问题

    ErrorException  : Array to string conversion

  at /var/www/html/app/Http/Controllers/Merchant/CountryAreaController.php:312
    308|             }
    309|         }
    310|         if (!empty($request->rental_service)) {
    311|             $service[] = 2;
  > 312|             foreach ($request->get('rental_vehicle_type' . []) as $item) {
    313|                 $area->VehicleType()->attach($item, ['service_type_id' => 2]);
    314|             }
    315|             $area->Package()->attach($request->rental_service, ['service_type_id' => 2]);
    316|         }

在错误的那一行,我改变了

foreach ($request->get('rental_vehicle_type' . []) as $item) {


array\u values()
解决了这个问题,我不知道为什么

你为什么要选择租车类型。[]?为什么不干脆
'rental_vehicle_type[]'
?老实说,这是一个非常老的项目,我现在不知道为什么在尝试第313行时要尝试其他错误检查代码Symfony\Component\Debug\Exception\fatalthrowable错误:语法错误,意外的'service_type_id'(T_字符串),预期','或''因此
数组到字符串的转换
错误得到了修复,您还有一个额外的错误吗?是的,但我通过foreach($request->get('rental_vehicle_type')。数组值([])作为$item进行了修复。{出于某种原因,我添加了数组值(),所有的错误都得到了解决,谢谢!
foreach ($request->get('rental_vehicle_type' . array_values([])) as $item) {