Skip to content

[13.x] Add foreignUuidFor schema helper#60091

Merged
taylorotwell merged 1 commit into
laravel:13.xfrom
Tresor-Kasenda:add-foreign-uuid-for
May 13, 2026
Merged

[13.x] Add foreignUuidFor schema helper#60091
taylorotwell merged 1 commit into
laravel:13.xfrom
Tresor-Kasenda:add-foreign-uuid-for

Conversation

@Tresor-Kasenda
Copy link
Copy Markdown
Contributor

This PR adds a foreignUuidFor helper to schema blueprints.

While foreignIdFor already supports UUID-backed Eloquent models by detecting the model key type, this new helper provides an explicit API for migrations that intentionally want a UUID foreign key column:

$table->foreignUuidFor(User::class)->constrained();

The helper mirrors the model-aware behavior of foreignIdFor by inferring:

  • the foreign key column name from the model
  • the related table name
  • the referenced primary key column

Introduce an explicit Blueprint helper for UUID-backed Eloquent relationships so migrations can mirror foreignIdFor while keeping the column type intentionally UUID-based.
@taylorotwell taylorotwell merged commit 7e53206 into laravel:13.x May 13, 2026
54 checks passed
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