Skip to content
This repository was archived by the owner on Nov 4, 2021. It is now read-only.

Commit eb58b28

Browse files
authored
Merge pull request #164 from michaelnguyen547/add-relation-to-whereGeoShape
added $relation to whereGeoShape
2 parents d412590 + 526cf10 commit eb58b28

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Builders/FilterBuilder.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,19 +366,21 @@ public function whereGeoPolygon($field, array $points)
366366
/**
367367
* Add a whereGeoShape condition.
368368
*
369-
* @see https://www.elastic.co/guide/en/elasticsearch/guide/current/querying-geo-shapes.html Querying Geo Shapes
369+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-query.html Querying Geo Shapes
370370
*
371371
* @param string $field
372372
* @param array $shape
373+
* @param string $relation
373374
* @return $this
374375
*/
375-
public function whereGeoShape($field, array $shape)
376+
public function whereGeoShape($field, array $shape, $relation = 'INTERSECTS')
376377
{
377378
$this->wheres['must'][] = [
378379
'geo_shape' => [
379380
$field => [
380381
'shape' => $shape,
381-
],
382+
'relation' => $relation
383+
]
382384
],
383385
];
384386

tests/Builders/FilterBuilderTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,10 @@ public function testWhereGeoShape()
350350
],
351351
];
352352

353+
$relation = 'WITHIN';
354+
353355
$builder = (new FilterBuilder($this->mockModel()))
354-
->whereGeoShape('foo', $shape);
356+
->whereGeoShape('foo', $shape, $relation);
355357

356358
$this->assertEquals(
357359
[
@@ -360,6 +362,7 @@ public function testWhereGeoShape()
360362
'geo_shape' => [
361363
'foo' => [
362364
'shape' => $shape,
365+
'relation' => $relation
363366
],
364367
],
365368
],

0 commit comments

Comments
 (0)