public function generateAllJsonFiles($dir, $makeGroupKeyClosure, $records, $groupKey)
    {
        if (! empty($groupKey)) {
            $records = $records->groupBy($groupKey);
        }

        $records->each(function (Coollection $record, $key) use ($dir, $makeGroupKeyClosure) {
            $this->helper->mkdir(dirname($file = $this->helper->makeJsonFileName($key, $dir)));

            $record = $record->mapWithKeys(function ($record, $key) use ($makeGroupKeyClosure) {
                $key = is_null($makeGroupKeyClosure)
                    ? $key
                    : $makeGroupKeyClosure($record, $key);

                $record = coollect($record)->sortBy(function ($value, $key) {
                    return $key;
                });

                return empty($key)
                    ? $record
                    : [$key => $record];
            })->sortByKeysRecursive();

            file_put_contents($file, $this->helper->jsonEncode($record));
        });
    }
public function generateAllJsonFiles($dir, $makeGroupKeyClosure, $records, $groupKey)
    {
        if (! empty($groupKey)) {
            $records = $records->groupBy($groupKey);
        }

        $records->each(function (Coollection $record, $key) use ($dir, $makeGroupKeyClosure) {
            $this->helper->mkdir(dirname($file = $this->helper->makeJsonFileName($key, $dir)));

            $record = $record->mapWithKeys(function ($record, $key) use ($makeGroupKeyClosure) {
                $key = is_null($makeGroupKeyClosure)
                    ? $key
                    : $makeGroupKeyClosure($record, $key);

                $record = coollect($record)->sortBy(function ($value, $key) {
                    return $key;
                });

                return empty($key)
                    ? $record
                    : [$key => $record];
            })->sortByKeysRecursive();

            file_put_contents($file, $this->helper->jsonEncode($record));
        });
    }
public function generateAllJsonFiles ( $ dir , $ makeGroupKeyClosure , $ records , $ groupKey ) { if ( ! empty ( $ groupKey ) ) { $ records = $ records -> groupBy ( $ groupKey ) ; } $ records -> each ( function ( Coollection $ record , $ key ) use ( $ dir , $ makeGroupKeyClosure ) { $ this -> helper -> mkdir ( dirname ( $ file = $ this -> helper -> makeJsonFileName ( $ key , $ dir ) ) ) ; $ record = $ record -> mapWithKeys ( function ( $ record , $ key ) use ( $ makeGroupKeyClosure ) { $ key = is_null ( $ makeGroupKeyClosure ) ? $ key : $ makeGroupKeyClosure ( $ record , $ key ) ; $ record = coollect ( $ record ) -> sortBy ( function ( $ value , $ key ) { return $ key ; } ) ; return empty ( $ key ) ? $ record : [ $ key => $ record ] ; } ) -> sortByKeysRecursive ( ) ; file_put_contents ( $ file , $ this -> helper -> jsonEncode ( $ record ) ) ; } ) ; }
Generate all json files.

@param $dir
@param Closure|null $makeGroupKeyClosure
@param \PragmaRX\Coollection\Package\Coollection $records
@param string|null $groupKey
Generate all json files .