diff --git a/.scrutinizer.yml b/.scrutinizer.yml index f09aa97..97f60be 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,2 +1,3 @@ tools: - external_code_coverage: true \ No newline at end of file + external_code_coverage: + runs: 2 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 19d35af..02ea093 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,9 @@ env: matrix: include: + - php: 5.6 + - php: 5.6 + env: COVERAGE=yes RELEASE=lowest - php: 7.0 - php: 7.1 - php: 7.2 diff --git a/composer.json b/composer.json index aefad9b..71bb761 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "illuminate/database": "~5.0" }, "require-dev": { - "phpunit/phpunit": "~6.5" + "phpunit/phpunit": "~5.7|~6.5" }, "autoload": { "psr-4": { diff --git a/src/Relations/BelongsToThrough.php b/src/Relations/BelongsToThrough.php index e95024e..e2db637 100644 --- a/src/Relations/BelongsToThrough.php +++ b/src/Relations/BelongsToThrough.php @@ -230,6 +230,31 @@ public function getRelationExistenceQuery(Builder $query, Builder $parent, $colu return $query; } + /** + * Add the constraints for a relationship count query. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param \Illuminate\Database\Eloquent\Builder $parent + * @return \Illuminate\Database\Eloquent\Builder + */ + public function getRelationCountQuery(Builder $query, Builder $parent) + { + return $this->getRelationExistenceQuery($query, $parent, new Expression('count(*)')); + } + + /** + * Add the constraints for a relationship query. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param \Illuminate\Database\Eloquent\Builder $parent + * @param array|mixed $columns + * @return \Illuminate\Database\Eloquent\Builder + */ + public function getRelationQuery(Builder $query, Builder $parent, $columns = ['*']) + { + return $this->getRelationExistenceQuery($query, $parent, $columns); + } + /** * Get the results of the relationship. * diff --git a/tests/BelongsToThroughTest.php b/tests/BelongsToThroughTest.php index 23b4d26..b9d0098 100644 --- a/tests/BelongsToThroughTest.php +++ b/tests/BelongsToThroughTest.php @@ -2,6 +2,7 @@ namespace Tests; +use Illuminate\Support\Arr; use Tests\Models\Comment; use Tests\Models\Post; @@ -62,6 +63,6 @@ public function testExistenceQuery() { $comments = Comment::has('country')->get(); - $this->assertEquals([31, 32, 33], $comments->pluck('id')->all()); + $this->assertEquals([31, 32, 33], Arr::pluck($comments, 'id')); } }