Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.4] Default foreign key for belongsTo relationship is now dynamic #16847

Merged
merged 2 commits into from
Dec 19, 2016
Merged

[5.4] Default foreign key for belongsTo relationship is now dynamic #16847

merged 2 commits into from
Dec 19, 2016

Conversation

ElMatella
Copy link
Contributor

@ElMatella ElMatella commented Dec 17, 2016

Following #16396 in order to make foreign keys more dynamics. Before, you needed to reference foreign key on belongsTo relationship if primary key of relation was not id:

class Foo extends Model 
{
    protected $primaryKey = 'key';
}

class Bar extends Model
{
    public function foo () 
    {
        return $this->belongsTo(Foo::class,'foo_key');
    }
}

Now, you should be able to just write:

class Bar extends Model
{
    public function foo () 
    {
        return $this->belongsTo(Foo::class);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants