If you don't care about the level of depth that gets converted, I think the simplest option for you is just the array_dot helper function.  If you want more granular control of how deep the recursion should go, and whether or not to have dot-delimited array keys, I've written a collection macro that can do that.  Typically collect($array)->collapse() maintains string keys, but non-incremental numeric ones still getting lost, even if type-forced to a string.  And I had a recent need to maintain them.
Put this in your AppServiceProvider::boot() method:
    /**
     * Flatten an array while keeping it's keys, even non-incremental numeric ones, in tact.
     *
     * Unless $dotNotification is set to true, if nested keys are the same as any
     * parent ones, the nested ones will supersede them.
     *
     * @param int $depth How many levels deep to flatten the array
     * @param bool $dotNotation Maintain all parent keys in dot notation
     */
    Collection::macro('flattenKeepKeys', function ($depth = 1, $dotNotation = false) {
        if ($depth) {
            $newArray = [];
            foreach ($this->items as $parentKey => $value) {
                if (is_array($value)) {
                    $valueKeys = array_keys($value);
                    foreach ($valueKeys as $key) {
                        $subValue = $value[$key];
                        $newKey = $key;
                        if ($dotNotation) {
                            $newKey = "$parentKey.$key";
                            if ($dotNotation !== true) {
                                $newKey = "$dotNotation.$newKey";
                            }
                            if (is_array($value[$key])) {
                                $subValue = collect($value[$key])->flattenKeepKeys($depth - 1, $newKey)->toArray();
                            }
                        }
                        $newArray[$newKey] = $subValue;
                    }
                } else {
                    $newArray[$parentKey] = $value;
                }
            }
            $this->items = collect($newArray)->flattenKeepKeys(--$depth, $dotNotation)->toArray();
        }
        return collect($this->items);
    });
Then you can call collect($a)->flattenKeepKeys(1, true); and get back what you're expecting.