diff --git a/src/BaseRepository.php b/src/BaseRepository.php index 1d21e1a..86a1431 100644 --- a/src/BaseRepository.php +++ b/src/BaseRepository.php @@ -42,6 +42,23 @@ public function with(array $relations) return $this; } + /** + * Query wether or not the relationship is empty of now. + * + * @param $relation + * @param string $operator + * @param int $count + * + * @return $this + */ + public function has($relation, $operator = '>=', $count = 1) + { + $this->builder = $this->builder->has($relation, $operator, $count); + + return $this; + } + + /** * By default a soft-deleted model does not return trashed. Use this * method to also fetch soft-deleted entries. diff --git a/src/BaseRepositoryInterface.php b/src/BaseRepositoryInterface.php index 6516be9..92e8d24 100644 --- a/src/BaseRepositoryInterface.php +++ b/src/BaseRepositoryInterface.php @@ -14,6 +14,17 @@ interface BaseRepositoryInterface */ public function with(array $relations); + /** + * Query wether or not the relationship is empty of now. + * + * @param $relation + * @param string $operator + * @param int $count + * + * @return $this + */ + public function has($relation, $operator = '>=', $count = 1); + /** * By default a soft-deleted model does not return trashed. Use this * method to also fetch soft-deleted entries.