Closed oroszgergely closed 4 years ago
This should work just fine, assuming your \HQ\Models\Content\Tag::class
extends \Cviebrock\EloquentTaggable\Models\Tag
. There is even a test in the package for exactly this case.
This proves to be an issue for me - where I am not able to change which model I extend from. I cannot tag models because of this. Unless you are willing to remove this type declaration - it leaves me two options:
Both options are not ideal.
Can you explain why this type declaration is needed?
Is there another way around this? - maybe a check could be done instead, like if($tag instancof $this->tagModel)
Hi there,
I would like to use a custom model for taggable, what I set up in the config file: 'model' => \HQ\Models\Content\Tag::class,
but if I try to get all the tags, it drops an error: Return value of Cviebrock\EloquentTaggable\Services\TagService::findOrCreate() must be an instance of Cviebrock\EloquentTaggable\Models\Tag, instance of HQ\Models\Content\Tag returned
So the function always wants to return the original model class, not the custom defined in the config file.
file: "/vendor/cviebrock/eloquent-taggable/src/Services/TagService.php" line: 55
Maybe all return type with Tag should be removed or changed to reflect the setting from the config file
Thanks