I have 3 tables :post , tag , tag_post.
I save post_id in post / tag_id in tag / and both of them in tag_post.
how can I show every post's tags ? how can I select data from tag_post table?
it's my Post model :
public function tag()
{
return $this->belongsToMany('Tag','tag_post');
}
and it's my Tag model :
public function post()
{
return $this->belongsToMany('Post','tag_post');
}
and it's my controller :
$posts=Post::orderBy('id','DESC')->paginate(5);
///but I dont know how can i show each post's tags under it
thanks for your time.