Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Can this package be used with a single polymorphic model? #152

Closed
MordiSacks opened this issue May 9, 2020 · 5 comments
Closed

Can this package be used with a single polymorphic model? #152

MordiSacks opened this issue May 9, 2020 · 5 comments
Assignees

Comments

@MordiSacks
Copy link

MordiSacks commented May 9, 2020

Instead of having
posts, posts_translations,
articles, articles_translations,
etc..
can I have
articles, posts,

and translations, something like this

        Schema::create('translations', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string("translatable_type");
            $table->unsignedBigInteger("translatable_id");
            $table->string('column', 70);
            $table->string('locale', 5);
            $table->text('value');
            $table->timestamps();
            $table->unique([
                'translatable_type',
                'translatable_id',
                'column',
                'locale',
            ], 'translations_u_type_id_column_locale');
        });
@Gummibeer
Copy link
Member

Hey,
yes you can use a single polymorphic table as long as this table contains all possible translatable columns.
You will have to override the translations() relationship method to use a polymorphic relation instead of a simple hasMany() and you will have to define the $translationModel property.
But the package isn't made and also not tested for polymorphic translations. So this could always break or require more adjustments.
Could also be that some of the scopes don't work because they only query the ID and not the type column.

@Gummibeer Gummibeer self-assigned this May 18, 2020
@MordiSacks
Copy link
Author

@Gummibeer
Thank you for your response, I will test this asap
and report result

@stale
Copy link

stale bot commented Jun 7, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 7, 2020
@stale
Copy link

stale bot commented Jul 5, 2020

This issue has been automatically closed because it has not had recent activity. Thank you for your contributions.

@stale stale bot closed this as completed Jul 5, 2020
@overclocked555
Copy link

@MordiSacks , hello! Of course, a lot of time has passed. :-)
Were you able to implement the polymorphic model?

@Astrotomic Astrotomic locked and limited conversation to collaborators Feb 7, 2024
@Gummibeer Gummibeer converted this issue into discussion #380 Feb 7, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Development

No branches or pull requests

3 participants