<p>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.</p>

CC BY-SA 4.0
2018-06-20T15:32:42.383Z
2018-06-20T15:32:42.383Z
Solspace
<p>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).</p>

<p>I'v tried (Among others):</p>

<pre><code>$calendarEvent = Event::find([
            'id' =&gt; $id,
        ])-&gt;with(['shows'])-&gt;all();
</code></pre>

<p>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:</p>

<pre><code>        {
            "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",

    ======&gt; "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
            }
        }
</code></pre>

<plugin-development><solspace><plugin-solspacecalendar>
Eager load elements from Solspace Plugin
# Eager load elements from Solspace Plugin

(Asked by: username_0 on 2018-06-19)

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
            }
        }

**Tags:** plugin-development, solspace, plugin-solspacecalendar

---

## 1 answers

### Answer by username_1 on 2018-06-20. Score: 1 | Accepted answer

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.


---

