Laravel queries all the articles under it through the tag tag.

post table is the article table, the primary key is id
tag table is the tag table, the primary key is id
post_tag is the intermediate mapping table, and the field is post_id,tag_id
now I want to select tag 1 to find out that all the
tags and articles under tag 1 are many-to-many
I set up a controller in the tag

clipboard.png

clipboard.png

clipboard.png

clipboard.png
the data I take out in this way is particularly troublesome to display on the page. Is there any better idea?

Feb.26,2021

finally figured it out.
rewrite the model code

clipboard.png

clipboard.png

Menu