I have a query where I am getting content based on array of taxonomies that I get, the array can look like this for example:
$userTaxonomies = ['administration', 'oslo'];
I am checking first for taxonomies that have the same slug as one of the user taxonomies, and then checking further for if the content if of type that I want, which is not relevant for this case:
$taxonomies = Taxonomy::whereIn('slug', $userTaxonomies)->with(['contents' => function($q) use ($contentType){
$q->where('ct_id', $contentType->id);
}])->get();
But, the problem I have is that now I get for each taxonomy contents, and since different taxonomies can have same content, I get same content multiple times, in this query. How can I get only distinct contents from this query so that they don't repeat for each taxonomy again?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2yOGqA6
via IFTTT
Aucun commentaire:
Enregistrer un commentaire