Skip to content

Commit 74c02e6

Browse files
ADD latitude and longitude to address helper
1 parent 263914b commit 74c02e6

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "wamesk/laravel-nova-address-field",
33
"description": "Laravel Nova 4 Address field",
44
"type": "library",
5-
"version": "1.4.2",
5+
"version": "1.4.3",
66
"license": "proprietary",
77
"require": {
88
"wamesk/laravel-nova-country": "^1.1|^2.0"

src/Utils/AddressHelper.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class AddressHelper
99
{
10-
public static function fakeAddress(array $data = [], bool $withName = true): AddressCast
10+
public static function fakeAddress(array $data = [], bool $withName = true, bool $withLatLng = false): AddressCast
1111
{
1212
if (!isset($data['first_name']) && $withName) {
1313
$data['first_name'] = fake()->firstName();
@@ -29,12 +29,19 @@ public static function fakeAddress(array $data = [], bool $withName = true): Add
2929
$data['country'] = fake()->countryCode();
3030
}
3131

32+
if (!isset($data['latitude']) && $withLatLng) {
33+
$data['latitude'] = fake()->latitude();
34+
}
35+
if (!isset($data['longitude']) && $withLatLng) {
36+
$data['longitude'] = fake()->longitude();
37+
}
38+
3239
return new AddressCast($data);
3340
}
3441

35-
public static function fakeCompanyAddress(array $data = []): AddressCast
42+
public static function fakeCompanyAddress(array $data = [], bool $withLatLng = false): AddressCast
3643
{
37-
$data = array_replace(self::fakeAddress(withName: false)->toArray(), $data);
44+
$data = array_replace(self::fakeAddress(withName: false, withLatLng: $withLatLng)->toArray(), $data);
3845

3946
$data['company'] = IsCompanyEnum::YES->value;
4047

0 commit comments

Comments
 (0)