2

I'm using Solspace plugin. I've related each event to a show. I want to get the event with its related show (Entry type).

I'v tried (Among others):

$calendarEvent = Event::find([
            'id' => $id,
        ])->with(['shows'])->all();

But, that gives me the event(✅) but in the show, I don't get the entry per se but I get like an unexecuted query. Looks something like:

        {
            "id": 22,
            "url": null,
            "title": "The Way You Sound",
            "slug": "the-way-you-sound",
            "start": "2018-12-14T18:00:00+00:00",
            "end": "2018-12-14T20:00:00+00:00",
            "allDay": false,
            "multiDay": false,
            "repeats": true,
            "readableRepeatRule": "Weekly on Friday, starting from Dec 14, 2018, forever",
            "calendar": {
                "id": 1,
                "name": "Shows",
                "handle": "default"
            },
            "site": {
                "id": "1",
                "name": "English",
                "handle": "default",
                "language": "en-US"
            },
            "editable": false,
            "enabled": true,
            "backgroundColor": "#C0BE11",
            "borderColor": "#868900",
            "textColor": "black",

    ======> "show": {
                "editable": false,
                "orderBy": {
                    "relations.sortOrder": 4
                },
                  ...
                "join": [
                    [
                        "INNER JOIN",
                        "{{%relations}} relations", [
                            "and",
                            "[[relations.targetId]] = [[elements.id]]",
                            {
                                "relations.sourceId": "22",
                                "relations.fieldId": "42"
                            },
                            [
                                "or",
                                {
                                    "relations.sourceSiteId": null
                                },
                                {
                                    "relations.sourceSiteId": "1"
                                }
                            ]
                        ]
                    ]
                ],
                "having": null,
                "union": null
            }
        }
1

Currently Calendar does not support eager loading, but it's much more likely the Craft 3 version will in the future, as we refactored a lot of code and tried to somewhat "normalize" the code to work more natively with Craft than we did in Craft 2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.