Support the ongoing development of Laravel.io →
posted 9 years ago
Eloquent
Last updated 2 years ago.
0

I understand your problem.
That is a One-to-One relationship.
BUT, using hasOne is wrong. It would be right if you hadn't any foreign keys in your match table, but istead in your team table (match_id). You have to use belognsTo instead. This means that the foreign key is in the table of the current model.
The relationship is correct, but you are looking from the wrong side.

Last updated 2 years ago.
0

How are your relationships defined in your model? Could you post that here?

From my understanding, your Team model should have a "belongsTo" relation towards Match, as you don't want to have a match_id column in your Team.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

quirkles quirkles Joined 1 Oct 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.