Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

adamjhn's avatar

Why 'id' is necessary in this query?

I have this query below to get the conference associated with the Registration.

Do you know why 'id' is necessary? Is because is the primary key of the conferences table and the foreign key in the registrations table? Even that in the registrations table this foreign key has the name "conference_id" and not just "id".

$registration = Registration::with([
    'conference' => function ($query) {
        $query->select('id', 'name', 'address');
    }
])->find($regID);


0 likes
3 replies
adamjhn's avatar

Thanks, so is the key of the conference model in this case?

Please or to participate in this conversation.