Skip to content
This repository has been archived by the owner on Feb 7, 2022. It is now read-only.

Commit

Permalink
Added has-method to pattern.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-Myrstad committed Dec 12, 2016
1 parent f28fc50 commit 87b406a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/BaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions src/BaseRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 87b406a

Please sign in to comment.