Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
fixed a bug where still an array was expected instead of the GeoAddre…
Browse files Browse the repository at this point in the history
…ss-model
  • Loading branch information
jerome2710 committed Oct 19, 2021
1 parent 85a6d96 commit 5466c6b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# TDE - Geo Address Changelog

## 1.0.15 - 2021-10-19
### Fixed
- Fixed a bug where still an array was expected instead of the GeoAddress-model.

## 1.0.14 - 2021-10-13
### Fixed
- Fixed an issue where existing GeoAddress-models would not be properly normalized/serialized into the element.
Expand Down
5 changes: 5 additions & 0 deletions src/models/GeoAddressModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ class GeoAddressModel extends Model
*/
public $formattedAddress;

/**
* @var float|null
*/
public $filterDistance;

/**
* Returns the validation rules for attributes.
*
Expand Down
12 changes: 5 additions & 7 deletions src/services/GeoAddressService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Craft;
use craft\base\Component;
use TDE\GeoAddress\GeoAddress;
use TDE\GeoAddress\models\GeoAddressModel;

/**
* Class GeoAddressService
Expand Down Expand Up @@ -116,13 +117,10 @@ public function filterEntries(array $entries, $lat, $lng, $radius)
}

// add the distance, might be useful for the user
$entry->setFieldValue(
'address',
array_merge(
$entry->getFieldValue('address'),
['filterDistance' => $filterDistance]
)
);
/** @var GeoAddressModel $model */
$model = $entry->getFieldValue('address');
$model->filterDistance = $filterDistance;
$entry->setFieldValue('address', $model);

$filterResults[] = $entry;
}
Expand Down

0 comments on commit 5466c6b

Please sign in to comment.