protected function prepareMultipartData($params)
    {
        $multipart = [];

        if ($params instanceof Arrayable) {
            $params = $params->toArray();
        }

        foreach ($params as $key => $value) {

            if ( ! is_array($value)) {

                $multipart[] = [
                    'name'     => $key,
                    'contents' => $value,
                ];

                continue;
            }

            foreach (array_dot($value) as $dotKey => $leafValue) {

                $partKey = $key
                    . implode(
                        array_map(
                            function($partKey) { return "[{$partKey}]"; },
                            explode('.', $dotKey)
                        )
                    );

                $multipart[] = [
                    'name'     => $partKey,
                    'contents' => $leafValue,
                ];
            }
        }
        
        return $multipart;
    }
protected function prepareMultipartData($params)
    {
        $multipart = [];

        if ($params instanceof Arrayable) {
            $params = $params->toArray();
        }

        foreach ($params as $key => $value) {

            if ( ! is_array($value)) {

                $multipart[] = [
                    'name'     => $key,
                    'contents' => $value,
                ];

                continue;
            }

            foreach (array_dot($value) as $dotKey => $leafValue) {

                $partKey = $key
                    . implode(
                        array_map(
                            function($partKey) { return "[{$partKey}]"; },
                            explode('.', $dotKey)
                        )
                    );

                $multipart[] = [
                    'name'     => $partKey,
                    'contents' => $leafValue,
                ];
            }
        }
        
        return $multipart;
    }
protected function prepareMultipartData ( $ params ) { $ multipart = [ ] ; if ( $ params instanceof Arrayable ) { $ params = $ params -> toArray ( ) ; } foreach ( $ params as $ key => $ value ) { if ( ! is_array ( $ value ) ) { $ multipart [ ] = [ 'name' => $ key , 'contents' => $ value , ] ; continue ; } foreach ( array_dot ( $ value ) as $ dotKey => $ leafValue ) { $ partKey = $ key . implode ( array_map ( function ( $ partKey ) { return "[{$partKey}]" ; } , explode ( '.' , $ dotKey ) ) ) ; $ multipart [ ] = [ 'name' => $ partKey , 'contents' => $ leafValue , ] ; } } return $ multipart ; }
Converts a given array with parameters to the multipart array format

@param array|Arrayable $params
@return array
Converts a given array with parameters to the multipart array format