Model::allTags() and related methods fail with Relation::enforceMorphMap()
anaxamaxan opened this issue · 1 comments
anaxamaxan commented
Please be sure you include all the relevant information in your issue so we can help you:
- steps taken to reproduce your issue
Installed per instructions. Using only one model so far, App\Models\Course, which implements Taggable with no overrides.
- your configuration file(s), where relevant
// AppServiceProvider::boot()
Relation::enforceMorphMap([
'course' => Course::class,
]);
- a copy of your Models that use or extend this package (just the relevant parts!)
Using the trait right out of the can:
class Course extends Model implements HasCommentsInterface, HasNotes
{
use HasFactory,
HasComments,
HasNotesTrait,
SoftDeletes,
Taggable;
// etc
}
- any other code we might need to help
The main issue comes from depending on php get_class()
in TagService::getAllTags()
and TagService::getPopularTags()
. Also the anonymous class in TagService::getQualifiedPivotTableName()
needs to either implement the getMorphClass()
method from Illuminate\Database\Eloquent\Concerns\HasRelationships
or otherwise get around the morph map enforcement.
I'll open a PR for the above.
cviebrock commented
Version 10.0.1 has been tagged with this fix. Thanks again @anaxamaxan !