Avoid nesting using the crossJoin and eachSpread collection functions original
While working on a package I found myself trying to combine some data. This is what my code looked like. Assume that $locales and $fields are arrays that are already populated. collect($locales)->each(function (string $locale) { collect($fields)->each(function (Field $field) use ($locale)…