Skip to content

How to check foreign keys? #43443

Answered by henzeb
JenuelDev asked this question in Q&A
Jul 27, 2022 · 2 comments · 2 replies
Discussion options

You must be logged in to vote

With getForeignKeyColumns() you can get an array of columns who are involved in a foreign key constraint.

With getForeignKeys() you get an arrray of ForeignKeyConstraint which has a method getLocalColumns with an array you can use to check if the column you want is involved.

I agree it's a little too much for something so simple, and we cannot add macro's to the Schema builder.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@JenuelDev
Comment options

Comment options

You must be logged in to vote
1 reply
@megabyte-0
Comment options

Answer selected by JenuelDev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants