custom_path_generators doesn't work with custom polymorphic types #3034
Unanswered
kskrlinnorth2
asked this question in
Ideas
Replies: 2 comments 3 replies
-
Could you send a PR for this? Be sure to also included a test to ensure it works. |
Beta Was this translation helpful? Give feedback.
1 reply
-
I have a similar issue and create the PR with the hotfix: |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using custom names for my morphed models, for example
user
instead ofApp\Models\User
and similar generated viaenforceMorphMap
method onIlluminate\Database\Eloquent\Relations\Relation
class, howevergetPathGeneratorClass
method can't work with such approach sinceis_a
expects full model namespaces so I can't use different custom path generators for each model.I fixed it with this block of code; could you update package with same or similar solution? Solution is to check if media model type exists in custom morphed list and then getting original model name via existing alias, otherwise just get the model type as in original code.
My installed package version is 10.3.6. (installed via this command:
composer require "spatie/laravel-medialibrary:^10.0.0"
)Beta Was this translation helpful? Give feedback.
All reactions