hcvbrandservices
2 years ago

Multiple Tag (Pivot Table) Searching

Posted 2 years ago by hcvbrandservices

I'm having some trouble finding a solution to something I'm trying to implement.

I have an Asset table and a Tags table. An Asset (ex. Image of a family in a pool) may have multiple tags attached to it ("kids", "parents", "pool", "family", "water").

I know how to ask for all assets associated with a single tag ("water")--but I can't figure out how to tell Laravel to give me only the assets that have the tags listed in an array (e.x. all images that are tagged with both "family" AND "water") and/or exclude assets with given tags (all images with "family" and "water" tags but not if they're also tagged "kids").

Can anyone help me with this?

Please sign in or create an account to participate in this conversation.