Specify MorphTo model #52336
Replies: 4 comments 3 replies
-
|
Nothing new here ? |
Beta Was this translation helpful? Give feedback.
-
|
I did a article about that - |
Beta Was this translation helpful? Give feedback.
-
|
I found a solution and wrote a blog post about it: https://hansvl.nl/blog/constraining-laravels-morphto-relation/ |
Beta Was this translation helpful? Give feedback.
-
Why? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello there,
In my use of Laravel I have several problem coming from the
morphTorelation because i'm not able to know what's related (this is the only relation behaving like this).A solution would be to use a
belongsTorelation but this breaks the SQL constraints of having a single model relatedIn my opinion it would be great to be able to specify optionnally what model you want from the relation so you avoid misleading results
Is this something that has been considered ? Or could be a great idea ?
My major problem is from my open source package: https://laravel-rest-api.lomkit.com/resources/relationships#morph-to
The workarrond i'm giving:
This is pretty bad for performances ... But this works
Beta Was this translation helpful? Give feedback.
All reactions