shahzadsarwar's avatar

Laravel Array to string conversion on multiple records

I'm trying to save multiple records at once..

When I try to store multiple records it gives an error of array to string conversion.

This is the response I get from axios.

array:2 [ 0 => array:3 [ "property_type_id" => 2 "fee_value" => "123" "product_service_id" => 1 ] 1 => array:3 [ "property_type_id" => 1 "fee_value" => "3333" "product_service_id" => 1 ] ]

my controller method

$feeByPropertyType = $request->feeByPropertyType;

    foreach ($feeByPropertyType as $row)
    {
        $data[] = [
            'property_type_id' => $row['property_type_id'],
            'fee_value' => $row['fee_value'],
            'product_service_id' => 1
        ];
    }

    PaymentTypeProductService::insert($data); 

Any help from the community will be greatly appreciated, on how to correct this. Thanks

0 likes
1 reply
bobbybouwmann's avatar

On what line do you get this error? As far as I know PaymentTypeProductService::insert($date) could be the problem as well. What is logic is behind there?

Please or to participate in this conversation.