Filtering many to many relations
Does anyone know how to filter based on two tables with  a many to many relations?  I keep geeting the following error
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tags' in 'where clause'
SELECT
  count(*) AS aggregate
FROM
  
tasks
WHERE
  (tags IN (2))14 Replies
add relationship to the filter?
Still doesn't work getting the same error
Try placing relationship at the bottom
I think i figured out the issue. The sql is searching for the column tags = 2 when it should search for the id = 2
so the query should look something like this 
Any tips on how i would go on with implementing this?
this is wrong 
->relationship('task_id', 'tag_id'). task_id should be the name of the relationship, not the column name.Ok but i think the issue stems from the fact that the filter is trying to select a value from the task table when instead it should do so from the table dedicated to their many to many relation task_tag. Where in the resource.php do i change the table from which te data is being taken from
sounds like your relationship might not be setup correctly.
I dont think so because in other cases where i display the data the relation is set up properly and its still displayed
its here when i try to filter
Because if i convert it to an array i get back the tag and the id of the task it belongs to
not sure then, but the method signature is ->relationship(name, titleAttribute) and if 'task_id' is the name of your relationship then something sounds off to me. Sorry.
Maybe I haven't really explained it properly
 this is the relation
and each of the models uses the 
 return $this->belongsToMany() what is the name of the relationship on your model class
in other scenarios where i display the tags beloning to the id everything works correctly
->relationship('tags', 'title')
->relationship('tags', 'id')
etc.
if you are on the Task list page
Now it worked. Thank you very much I geniunely appreciate it
was struggling with this for like 2 hours