-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/DivineOmega/laravel-addre…
- Loading branch information
Showing
8 changed files
with
123 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/vendor/ | ||
composer.lock | ||
.idea | ||
.idea | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
|
||
namespace DivineOmega\LaravelAddresses\Helpers; | ||
|
||
|
||
use DivineOmega\Countries\Countries; | ||
use DivineOmega\Countries\Country; | ||
|
||
abstract class CountryHelper | ||
{ | ||
static $countriesByCode = []; | ||
|
||
static function getByIsoCode($countryCode): ?Country | ||
{ | ||
if (array_key_exists($countryCode, self::$countriesByCode)) { | ||
return self::$countriesByCode[$countryCode]; | ||
} | ||
|
||
$country = (new Countries())->getByIsoCode($countryCode); | ||
|
||
self::$countriesByCode[$countryCode] = $country; | ||
|
||
return $country; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
<?php | ||
|
||
return [ | ||
'validation' => [ | ||
'uk-postcode' => true, | ||
'country-code' => true, | ||
], | ||
'geocoding' => [ | ||
'enabled' => true, | ||
'google-maps' => [ | ||
'api-key' => env('GEOCODING_GOOGLE_MAPS_API_KEY'), | ||
] | ||
], | ||
'strict' => false, | ||
] | ||
]; |
32 changes: 32 additions & 0 deletions
32
src/database/migrations/2020_12_14_113555_add_addressable_index.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class AddAddressableIndex extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::table('addresses', function (Blueprint $table) { | ||
$table->index(['addressable_type', 'addressable_id']); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::table('addresses', function (Blueprint $table) { | ||
$table->dropIndex(['addressable_type', 'addressable_id']); | ||
}); | ||
} | ||
} |