Hi,
I'm building a blog plugin so I have all my needs. I have one more issue where I can't find any solution for.I'm using tags for this plugin. What I now want to do is to show all post related to a tag.
The relation in the tag model:
public $belongsToMany = [
'posts' => [
'wouter\Blog\Models\Post',
'table' => 'wouter_blog_posts'
],
];
The relation in de post model:
public $belongsToMany = [
'tags' => [
'wouter\Blog\Models\Tags',
'table' => 'wouter_blog_posts_tags'
],
];
In my components file i try to query the tags to get the related posts
BlogTag::where('slug', '=', 'test-slug')->with('posts')->get();
When above query is running i get a exception but i don't see / understand what i do wrong. I think my relation in the model tag is not right but i can't find what other relation to use.
An exception has been thrown during the rendering of a template ("SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'wouter_blog_posts' (SQL: select
wouter_blog_posts.*,wouter_blog_posts.tags_idaspivot_tags_id,wouter_blog_posts.post_idaspivot_post_idfromwouter_blog_postsinner joinwouter_blog_postsonwouter_blog_posts.id=wouter_blog_posts.post_idwherewouter_blog_posts.tags_idin (11))").
I hope someone can help me.