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.8] Add the proper columns for a polymorphic table (using uuid for the {$name}_id column) #29289

Merged
merged 2 commits into from
Jul 25, 2019

Conversation

diamondobama
Copy link
Contributor

This allows creating polymorphic columns with the id being uuid without the need to manually create individual columns and index them afterward.

@taylorotwell taylorotwell merged commit 46e2d0e into laravel:5.8 Jul 25, 2019
@GrahamCampbell GrahamCampbell changed the title Add the proper columns for a polymorphic table (using uuid for the {$name}_id column) [5.8] Add the proper columns for a polymorphic table (using uuid for the {$name}_id column) Jul 28, 2019
@rjvim
Copy link

rjvim commented Jul 21, 2020

Hi,

When we use something like:

   public function commentable()
    {
        return $this->morphTo();
    }

How do you propose to use this relationship when we use uuidMorphs. This relationship is not working as it's expecting id to be an integer in the other table.

@diamondobama
Copy link
Contributor Author

diamondobama commented Jul 21, 2020

@rjvim Did you set below in the model you are morphing to?

/**
 * The "type" of the primary key ID.
 *
 * @var string
 */
protected $keyType = 'string';

@rjvim
Copy link

rjvim commented Jul 21, 2020

Hi,

I didnt set this one.

But it worked even without it. In the other table, I had to set column type to "uuid".

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