Answer the question
In order to leave comments, you need to log in
How to take tags only belonging to that model?
posts
id - integer
name - string
videos
id - integer
name - string
tags
id - integer
name - string
taggables
tag_id - integer
taggable_id - integer
taggable_type - string
videos
in select, only tags
those that belong to videos
. tags
add type
and write the name of the table there and query scopes
filter through each model separately. But is there an easier way to do this?
Answer the question
In order to leave comments, you need to log in
So what's the problem, everything is in the documentation, relation polymorph:
https://laravel.com/docs/8.x/eloquent-relationship...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question