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

[7.x] Add dynamic 'column' key for foreign constraints #32449

Merged
merged 3 commits into from
Apr 20, 2020
Merged

[7.x] Add dynamic 'column' key for foreign constraints #32449

merged 3 commits into from
Apr 20, 2020

Conversation

reed-jones
Copy link
Contributor

This change enables using the new (7.x) foreign key ($table->foreignId('user_id')->constrained();) syntax on tables not using 'id' as their primaryKey. Previously only the table could be specified.

As an example

    $table->foreignId('festival_year')->constrained('festivals', 'year');

would be the equivalent to the previous syntax of

    $table->unsignedBigInteger('festival_year');
    $table->foreign('festival_year')->references('year')->on('festivals');

@tomstreeter
Copy link

I’ve complained in the past about the frequency of updates. I’ll stop now because this cleanly solves a problem I didn’t realize I had until yesterday.

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.

3 participants