First negative search query

This commit is contained in:
James Cole
2022-09-24 18:06:01 +02:00
parent a9f2741282
commit 80a732b32b
5 changed files with 57 additions and 7 deletions

View File

@@ -408,6 +408,23 @@ trait MetaCollection
return $this;
}
/**
* Limit the search to a specific bunch of categories.
*
* @param Collection $categories
*
* @return GroupCollectorInterface
*/
public function setNotCategories(Collection $categories): GroupCollectorInterface
{
if ($categories->count() > 0) {
$this->withCategoryInformation();
$this->query->whereNotIn('categories.id', $categories->pluck('id')->toArray());
}
return $this;
}
/**
* Will include category ID + name, if any.
*

View File

@@ -571,6 +571,15 @@ interface GroupCollectorInterface
*/
public function setCategories(Collection $categories): GroupCollectorInterface;
/**
* Limit the search not to have a specific bunch of categories.
*
* @param Collection $categories
*
* @return GroupCollectorInterface
*/
public function setNotCategories(Collection $categories): GroupCollectorInterface;
/**
* Limit the search to a specific category.
*