-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Polymorphic Relations #26
Comments
This is not supported yet, but I'll look into it. |
Can you provide details about your use case? |
In my use case I have all images in media table where I can refer to it from any model with morphOne or morphMany. Initialy I want to set user's profile picture in json column in users table, but since this isn't supported yet I just set the user's profile picture in its own column. but I think it will be nice to have this morphOne or morphMany relationship in json column, since by default every user get default gravatar (or anything) profile picture and not really required to change the profile picture, so we don't get lots of image column with null values. Thanks by the way, this really is a great package. |
@zickcrow Thanks for the use case. Can you share the migration/structure of your |
CREATE TABLE FYI,I use https://docs.spatie.be/laravel-medialibrary/v8/introduction/ which generates this table |
@zickcrow It's actually already possible to use a JSON column here. Regarding your setup: You are connecting user and image with a column in the |
Yes and no, its my mistake. I think you can close this now. Thanks |
@staudenmeir PHP actually encodes arrays as JSON object arrays and since this is for laravel, it would be useful to have this. |
What do you mean by that? What do your tables and JSON values look like? What relationship(s) have you tried? |
Is morphTo and morphToMany supported? |
@asandri-mmo What do your tables look like? |
Schema::create('candidates', function (Blueprint $table) { Schema::create('jobs', function (Blueprint $table) { Schema::create('applications', function (Blueprint $table) { Schema::create('messages', function (Blueprint $table) { Messageable Types are candidates, jobs, applications Please help |
@asandri-mmo This case is not supported yet. |
Hi,
love the package, but I cant seem to get polymorphic relations working from within the JSON column.
For example, if I have a User model with a JSON column named 'custom_fields' which is an array of objects. Would it be possible to store something like
[ { 'relationable_id': 12, 'relationable_type: 'App/Role' }, { 'relationable_id': 13, 'relationable_type: 'App/Permission' } ]
Can you provide an example of doing many to many polymorphic relations?
The text was updated successfully, but these errors were encountered: