I am struggling with the following query, using Eloquent in Laravel 5.6.
I need to return all issues that have a tag_id
of 5
assigned to them, where the project_id
and item_id
from the issues table matches the project_id
and issue_id
from my pivot table.
issues table:
issues_tags pivot table:
I have tried the following code, but it returns all issues from the issue table, however the expectation is 3 results.
Expected results
The results returned from the issues
table should be ID 1, 4 and 5.
$issues = Issue::join('issues_tags', 'issues_tags.project_id', 'issues_tags.issue_id')->where('issues_tags.tag_id', 5)->select('issues.*')->get();