Answer the question
In order to leave comments, you need to log in
How to get data from many to many correctly?
Hello, I made MTM as in the documentation and the problem is that I use MTM in the form of getting tags from posts.
Inside the post, everything works fine, but outside - no. I would like to place them on the main page via "@foreach"
https://github.com/ChampionTommy/laravel-blog/tree... - models
https://github.com/ChampionTommy/laravel-blog/tree.. . -db
I can't figure out how it's done? Maybe I didn't look at the documentation properly or missed something...Poke your finger please...
Tried via Tinker - Tags::with('posts')->first() and get null. But it highlights the tags with the usual get ()
As if I have no connection with the posts model
upd: Perhaps I should specify the post_id in the db Tags and take the value from there, it happened to me when I did "one to many"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question