Skip to content

Commit 033957b

Browse files
committed
added having cities filter
1 parent 3c4ad1b commit 033957b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/Resource/CountryResource.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ public function retrieveCountries($subject, $options = [])
2424
'from' => [
2525
'type' => 'string',
2626
],
27+
'having' => [
28+
'type' => 'string',
29+
'enum' => ['cities'],
30+
],
2731
'region_id' => [
2832
'type' => 'integer',
2933
'minimum' => 1,
@@ -42,6 +46,9 @@ public function retrieveCountries($subject, $options = [])
4246
if (isset($options['region_id'])) {
4347
$query->where('region_id', $options['region_id']);
4448
}
49+
if (isset($options['having'])) {
50+
$query->has($options['having']);
51+
}
4552
return new Paginator($query, $options);
4653
}
4754
}

src/Resource/RegionResource.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ public function retrieveRegions($subject, $options = [])
2424
'from' => [
2525
'type' => 'string',
2626
],
27+
'having' => [
28+
'type' => 'string',
29+
'enum' => ['cities'],
30+
],
2731
]);
2832
$v = $this->validation->fromSchema($pagSch);
2933
$options = $this->validation->prepareData($pagSch, $options, true);
@@ -35,6 +39,10 @@ public function retrieveRegions($subject, $options = [])
3539
$q->distance('point', new Point($a, $b), $options['distance']);
3640
});
3741
}
42+
// TODO mejorar porque no es dinámico
43+
if (isset($options['having'])) {
44+
$query->has('countries.cities');
45+
}
3846
return new Paginator($query, $options);
3947
}
4048
}

0 commit comments

Comments
 (0)