Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistencies in the encoding of collections results in some JS arrays, and some JS objects? #65

Open
lukeify opened this issue Oct 26, 2015 · 0 comments

Comments

@lukeify
Copy link

lukeify commented Oct 26, 2015

I'm converting the following PHP collections to JS variables:

    JavaScript::put([
        // <snip>
        'launchVideos'      => $missionObjects->where('subtype', MissionControlSubtype::LaunchVideo)->filter(function($item) {
                                    return $item->external_url != null;
                                }),
        'missionPatches'    => $missionObjects->where('subtype', MissionControlSubtype::MissionPatch),
        'pressKits'         => $missionObjects->where('subtype', MissionControlSubtype::PressKit),
        'cargoManifests'    => $missionObjects->where('subtype', MissionControlSubtype::CargoManifest),
        'pressConferences'  => $missionObjects->where('subtype', MissionControlSubtype::PressConference)->filter(function($item) {
                                    return $item->external_url != null;
                                }),
        'featuredImages'    => $missionObjects->where('subtype', MissionControlSubtype::Photo)
    ]);

Take particular note of featuredImages and missionPatches. They each have 1 member in the collection, once where'd.

Yet, the former is cast to a JS object, and the latter is cast to a JS array:

Wat

I am not doing any mutating on the front end, this is the raw output. Can anyone explain why this is occurring?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant