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

Or could it be that foreign key on 'players' table has to be named differently (dbnation_id ? )?

Last updated 2 years ago.
0

You need to do it as follows:

class Player extends Eloquent {

    public function dbnation()
    {
        return $this->belongsTo('DbNation', 'nation_id');
    }

}

The second parameter in the "belongsTo" function will define the local key for the relationship.

Last updated 2 years ago.
0

aka, rtfm.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

akalajzi akalajzi Joined 9 Feb 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.