Get list of countries from countries-laravel package (#1117)

This commit is contained in:
Alexis Saettler
2018-05-08 18:30:35 +02:00
committed by GitHub
parent 845d65b821
commit 67171c0309
40 changed files with 1128 additions and 174 deletions
+1 -2
View File
@@ -65,7 +65,7 @@ command7: &wait-for-server
command8: &unit-tests
run:
name: Run unit tests
command: phpdbg -qrr vendor/bin/phpunit -c phpunit.xml
command: phpdbg -dmemory_limit=4G -qrr vendor/bin/phpunit -c phpunit.xml --log-junit ./results/junit.xml --coverage-clover ./results/coverage.xml
command9: &psalm
run:
name: Run psalm
@@ -90,7 +90,6 @@ command13: &remove-xdebug
name: Remove xdebug
command: |
sudo rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
echo "memory_limit=512M" | sudo tee /usr/local/etc/php/php.ini
restore_cache1: &restore_composer
restore_cache:
Binary file not shown.
+1
View File
@@ -1,6 +1,7 @@
UNRELEASED CHANGES:
* Remove automatic birthday reminder creation when editing a contact
* Use external list of countries, with translations and reliability
RELEASED VERSIONS:
+4 -75
View File
@@ -2,6 +2,7 @@
namespace App;
use App\Helpers\CountriesHelper;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -36,16 +37,6 @@ class Address extends Model
return $this->belongsTo(Contact::class);
}
/**
* Get the Country records associated with the contact.
*
* @return BelongsTo
*/
public function country()
{
return $this->belongsTo('App\Country');
}
/**
* Get the address in a format like 'Lives in Scranton, MS'.
*
@@ -91,7 +82,7 @@ class Address extends Model
$address .= ' '.$this->postal_code;
}
if (! is_null($this->country_id)) {
if (! is_null($this->country)) {
$address .= ' '.$this->getCountryName();
}
@@ -113,19 +104,7 @@ class Address extends Model
public function getCountryName()
{
if ($this->country) {
return $this->country->country;
}
}
/**
* Get the country ISO of the contact.
*
* @return string or null
*/
public function getCountryISO()
{
if ($this->country) {
return $this->country->iso;
return CountriesHelper::get($this->country);
}
}
@@ -139,56 +118,6 @@ class Address extends Model
$address = $this->getFullAddress();
$address = urlencode($address);
return "https://www.google.ca/maps/place/{$address}";
}
/**
* Get the name of the address.
*
* @return string
*/
public function getNameAttribute($value)
{
return $value;
}
/**
* Get the street of the address.
*
* @return string
*/
public function getStreetAttribute($value)
{
return $value;
}
/**
* Get the city of the address.
*
* @return string
*/
public function getCityAttribute($value)
{
return $value;
}
/**
* Get the province of the address.
*
* @return string
*/
public function getProvinceAttribute($value)
{
return $value;
}
/**
* Get the postal code of the address.
*
* @return string
*/
public function getPostalCodeAttribute($value)
{
return $value;
return "https://www.google.com/maps/place/{$address}";
}
}
-1
View File
@@ -35,7 +35,6 @@ class SetupTest extends Command
$this->artisan('✓ Performing migrations', 'migrate:fresh');
$this->artisan('✓ Filling the Activity Types table', 'db:seed', ['--class' => 'ActivityTypesTableSeeder']);
$this->artisan('✓ Filling the Countries table', 'db:seed', ['--class' => 'CountriesSeederTable']);
$this->artisan('✓ Symlink the storage folder', 'storage:link');
if (! $this->option('skipSeed')) {
-3
View File
@@ -86,9 +86,6 @@ class Update extends Command
if (DB::table('activity_types')->count() == 0) {
$this->commandExecutor->artisan('✓ Filling the Activity Types table', 'db:seed', ['--class' => 'ActivityTypesTableSeeder', '--force' => 'true']);
}
if (DB::table('countries')->count() == 0) {
$this->commandExecutor->artisan('✓ Filling the Countries table', 'db:seed', ['--class' => 'CountriesSeederTable', '--force' => 'true']);
}
if ($this->getLaravel()->environment() != 'testing' && ! file_exists(public_path('storage'))) {
$this->commandExecutor->artisan('✓ Symlink the storage folder', 'storage:link');
}
-10
View File
@@ -1,10 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Country extends Model
{
protected $table = 'countries';
}
+85
View File
@@ -0,0 +1,85 @@
<?php
namespace App\Helpers;
use Illuminate\Support\Collection;
class CollectionHelper
{
/**
* Sort the collection using the given callback.
*
* @param callable|string $callback
* @param int $options
* @param bool $descending
* @return static
*/
public static function sortByCollator($collect, $callback, $options = \Collator::SORT_STRING, $descending = false)
{
$results = [];
$callback = static::valueRetriever($callback);
// First we will loop through the items and get the comparator from a callback
// function which we were given. Then, we will sort the returned values and
// and grab the corresponding values for the sorted keys from this array.
foreach ($collect->all() as $key => $value) {
$results[$key] = $callback($value, $key);
}
// Using Collator to sort the array, with locale-sensitive sort ordering support.
static::getCollator()->asort($results, $options);
if ($descending) {
$results = array_reverse($results);
}
// Once we have sorted all of the keys in the array, we will loop through them
// and grab the corresponding model so we can set the underlying items list
// to the sorted version. Then we'll just return the collection instance.
foreach (array_keys($results) as $key) {
$results[$key] = $collect->get($key);
}
return new Collection($results);
}
/**
* Get a Collator object for the locale or current locale.
*
* @param string
* @return \Collator
*/
public static function getCollator($locale = null)
{
static $collators = [];
if (! $locale) {
$locale = app()->getLocale();
}
if (! array_has($collators, $locale)) {
$collator = new \Collator($locale);
$collators[$locale] = $collator;
return $collator;
}
return $collators[$locale];
}
/**
* Get a value retrieving callback.
*
* @param string $value
* @return callable
*/
private static function valueRetriever($value)
{
if (! is_string($value) && is_callable($value)) {
return $value;
}
return function ($item) use ($value) {
return data_get($item, $value);
};
}
}
+62
View File
@@ -0,0 +1,62 @@
<?php
namespace App\Helpers;
use Illuminate\Support\Facades\App;
use PragmaRX\CountriesLaravel\Package\Facade as Countries;
class CountriesHelper
{
/**
* Get list of countries.
*
* @return \Illuminate\Support\Collection
*/
public static function getAll()
{
$countries = Countries::all()->map(function ($item) {
return [
'id' => $item->cca2,
'country' => static::getCommonNameLocale($item),
];
});
return CollectionHelper::sortByCollator($countries, 'country');
}
public static function get($iso)
{
$country = Countries::where('cca2', mb_strtoupper($iso))->first();
if ($country->count() === 0) {
$country = Countries::where('alt_spellings', mb_strtoupper($iso))->first();
}
if ($country->count() === 0) {
return '';
}
return static::getCommonNameLocale($country);
}
public static function find($name)
{
$country = Countries::where('name.common', $name)->first();
if ($country->count() === 0) {
$country = Countries::where('cca2', mb_strtoupper($name))->first();
}
if ($country->count() === 0) {
return '';
}
return $country->cca2;
}
private static function getCommonNameLocale($country)
{
$locale = App::getLocale();
$lang = LocaleHelper::getLocaleAlpha($locale);
return array_get($country, 'translations.'.$lang.'.common',
array_get($country, 'name.common', '')
);
}
}
+32 -1
View File
@@ -2,6 +2,7 @@
namespace App\Helpers;
use Matriphe\ISO639\ISO639;
use Illuminate\Support\Facades\Auth;
class LocaleHelper
@@ -42,7 +43,7 @@ class LocaleHelper
]);
}
return $locales->sortBy('name');
return CollectionHelper::sortByCollator($locales, 'name');
}
/**
@@ -73,4 +74,34 @@ class LocaleHelper
return 'ltr';
}
}
/**
* Association ISO-639-1 => ISO-639-2.
*/
private static $locales = [];
/**
* Get ISO-639-2/t (three-letter codes) from ISO-639-1 (two-letters code).
*
* @param string
* @return string
*/
public static function getLocaleAlpha($locale)
{
if (array_has(static::$locales, $locale)) {
return array_get(static::$locales, $locale);
}
$locale = mb_strtolower($locale);
$languages = (new ISO639)->allLanguages();
$lang = '';
foreach ($languages as $l) {
if ($l[0] == $locale) {
$lang = $l[1];
break;
}
}
static::$locales[$locale] = $lang;
return $lang;
}
}
@@ -101,7 +101,7 @@ class ApiAddressController extends ApiController
'city' => 'max:255|nullable',
'province' => 'max:255|nullable',
'postal_code' => 'max:255|nullable',
'country_id' => 'integer|nullable',
'country' => 'max:3|nullable',
'contact_id' => 'required|integer',
]);
@@ -2,8 +2,8 @@
namespace App\Http\Controllers\Api\Misc;
use App\Country;
use Illuminate\Http\Request;
use App\Helpers\CountriesHelper;
use App\Http\Controllers\Api\ApiController;
use App\Http\Resources\Country\Country as CountryResource;
@@ -16,7 +16,7 @@ class ApiCountryController extends ApiController
*/
public function index(Request $request)
{
$countries = Country::orderBy('country', 'asc')->get();
$countries = CountriesHelper::getAll();
return CountryResource::collection($countries);
}
@@ -4,7 +4,7 @@ namespace App\Http\Controllers\Contacts;
use App\Address;
use App\Contact;
use App\Country;
use App\Helpers\CountriesHelper;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use App\Http\Requests\People\AddressesRequest;
@@ -24,7 +24,8 @@ class AddressesController extends Controller
'name' => $address->name,
'googleMapAddress' => $address->getGoogleMapAddress(),
'address' => $address->getFullAddress(),
'country_id' => $address->country_id,
'country' => $address->country,
'country_name' => $address->country_name,
'street' => $address->street,
'city' => $address->city,
'province' => $address->province,
@@ -42,7 +43,7 @@ class AddressesController extends Controller
*/
public function getCountries()
{
return Country::orderBy('country')->get();
return CountriesHelper::getAll()->all();
}
/**
@@ -52,7 +53,7 @@ class AddressesController extends Controller
{
return $contact->addresses()->create([
'account_id' => auth()->user()->account->id,
'country_id' => ($request->get('country_id') == 0 ? null : $request->get('country_id')),
'country' => ($request->get('country') == '0' ? null : $request->get('country')),
'name' => ($request->get('name') == '' ? null : $request->get('name')),
'street' => ($request->get('street') == '' ? null : $request->get('street')),
'city' => ($request->get('city') == '' ? null : $request->get('city')),
@@ -67,7 +68,7 @@ class AddressesController extends Controller
public function edit(AddressesRequest $request, Contact $contact, Address $address)
{
$address->update([
'country_id' => ($request->get('country_id') == 0 ? null : $request->get('country_id')),
'country' => ($request->get('country') == '' ? null : $request->get('country')),
'name' => ($request->get('name') == '' ? null : $request->get('name')),
'street' => ($request->get('street') == '' ? null : $request->get('street')),
'city' => ($request->get('city') == '' ? null : $request->get('city')),
@@ -24,7 +24,7 @@ class AddressesRequest extends FormRequest
public function rules()
{
return [
'country_id' => 'integer|nullable',
'country' => 'max:3|nullable',
'name' => 'max:255|nullable',
'street' => 'max:255|nullable',
'city' => 'max:255|nullable',
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Http\Resources\Country;
use App\Helpers\CountriesHelper;
use Illuminate\Http\Resources\Json\Resource;
class Country extends Resource
@@ -17,8 +18,8 @@ class Country extends Resource
return [
'id' => $this->id,
'object' => 'country',
'name' => $this->country,
'iso' => $this->iso,
'name' => CountriesHelper::get($this->id),
'iso' => $this->id,
];
}
}
@@ -2,15 +2,11 @@
namespace App\Http\ViewComposers;
use App\Country;
use Illuminate\View\View;
use App\Helpers\CountriesHelper;
class CountrySelectViewComposer
{
public function __construct()
{
}
/**
* Bind data to the view.
*
@@ -19,7 +15,8 @@ class CountrySelectViewComposer
*/
public function compose(View $view)
{
$countries = Country::orderBy('country', 'asc')->get();
$countries = CountriesHelper::getAll()->all();
$view->with('countries', $countries);
}
}
+5 -6
View File
@@ -4,6 +4,7 @@ namespace App;
use Exception;
use Sabre\VObject\Reader;
use App\Helpers\CountriesHelper;
use Sabre\VObject\Component\VCard;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;
@@ -486,12 +487,10 @@ class ImportJob extends Model
$address->province = $this->formatValue($this->currentEntry->ADR->getParts()[4]);
$address->postal_code = $this->formatValue($this->currentEntry->ADR->getParts()[5]);
$country = \App\Country::where('country', $this->currentEntry->ADR->getParts()[6])
->orWhere('iso', mb_strtolower($this->currentEntry->ADR->getParts()[6]))
->first();
if ($country) {
$address->country_id = $country->id;
$iso = CountriesHelper::find($this->currentEntry->ADR->getParts()[6]);
if ($iso) {
$address->country = $iso;
}
$address->contact_id = $contact->id;
-1
View File
@@ -17,7 +17,6 @@ class ExportAccountAsSQL
'activity_types',
'api_usage',
'cache',
'countries',
'currencies',
'default_contact_field_types',
'default_contact_modules',
+2 -10
View File
@@ -5,10 +5,10 @@ namespace App\Traits;
use App\Gender;
use App\Address;
use App\Contact;
use App\Country;
use App\ContactField;
use App\ContactFieldType;
use Sabre\VObject\Reader;
use App\Helpers\CountriesHelper;
use Sabre\VObject\Component\VCard;
trait VCardImporter
@@ -104,15 +104,7 @@ trait VCardImporter
$address->city = $this->formatValue($vcard->ADR->getParts()[3]);
$address->province = $this->formatValue($vcard->ADR->getParts()[4]);
$address->postal_code = $this->formatValue($vcard->ADR->getParts()[5]);
$country = Country::where('country', $vcard->ADR->getParts()[6])
->orWhere('iso', mb_strtolower($vcard->ADR->getParts()[6]))
->first();
if ($country) {
$address->country_id = $country->id;
}
$address->country = CountriesHelper::find($vcard->ADR->getParts()[6]);
$address->contact_id = $contact->id;
$address->account_id = $contact->account_id;
$address->save();
+2
View File
@@ -24,7 +24,9 @@
"laravel/socialite": "^3.0",
"league/flysystem-aws-s3-v3": "~1.0",
"mariuzzo/laravel-js-localization": "^1.4",
"matriphe/iso-639": "^1.0",
"paragonie/constant_time_encoding": "^2.2",
"pragmarx/countries-laravel": "^0.5.2",
"pragmarx/google2fa": "^3.0",
"pragmarx/google2fa-laravel": "^0.2",
"pragmarx/recovery": "^0.1",
Generated
+717 -3
View File
@@ -1,10 +1,10 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "8571080164d4b93be3c478bcd67bfe3d",
"content-hash": "654c35e2a59e4ad320a8eff5c8fc57c4",
"packages": [
{
"name": "aws/aws-sdk-php",
@@ -176,6 +176,70 @@
],
"time": "2017-04-04T11:38:05+00:00"
},
{
"name": "colinodell/json5",
"version": "v1.0.4",
"source": {
"type": "git",
"url": "https://github.com/colinodell/json5.git",
"reference": "a720fbdaa07c802797524ab46575a74a6ac30719"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/colinodell/json5/zipball/a720fbdaa07c802797524ab46575a74a6ac30719",
"reference": "a720fbdaa07c802797524ab46575a74a6ac30719",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-mbstring": "*",
"php": "^5.4.8|^7.0"
},
"require-dev": {
"mikehaertl/php-shellcommand": "^1.2.5",
"phpunit/phpunit": "^4.8.36",
"squizlabs/php_codesniffer": "^2.3",
"symfony/finder": "^2.3"
},
"bin": [
"bin/json5"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": {
"psr-4": {
"ColinODell\\Json5\\": "src"
},
"files": [
"src/global.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Colin O'Dell",
"email": "colinodell@gmail.com",
"homepage": "https://www.colinodell.com",
"role": "Developer"
}
],
"description": "UTF-8 compatible JSON5 parser for PHP",
"homepage": "https://github.com/colinodell/json5",
"keywords": [
"JSON5",
"json",
"json5_decode",
"json_decode"
],
"time": "2018-01-14T23:52:11+00:00"
},
{
"name": "creativeorange/gravatar",
"version": "v1.0.11",
@@ -2002,7 +2066,7 @@
{
"name": "Luís Otávio Cobucci Oblonczyk",
"email": "lcobucci@gmail.com",
"role": "developer"
"role": "Developer"
}
],
"description": "A simple library to work with JSON Web Token and JSON Web Signature",
@@ -2407,6 +2471,50 @@
],
"time": "2017-11-23T04:07:56+00:00"
},
{
"name": "matriphe/iso-639",
"version": "1.2",
"source": {
"type": "git",
"url": "https://github.com/matriphe/php-iso-639.git",
"reference": "0245d844daeefdd22a54b47103ffdb0e03c323e1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/matriphe/php-iso-639/zipball/0245d844daeefdd22a54b47103ffdb0e03c323e1",
"reference": "0245d844daeefdd22a54b47103ffdb0e03c323e1",
"shasum": ""
},
"require-dev": {
"phpunit/phpunit": "^4.7"
},
"type": "library",
"autoload": {
"psr-4": {
"Matriphe\\ISO639\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Muhammad Zamroni",
"email": "halo@matriphe.com"
}
],
"description": "PHP library to convert ISO-639-1 code to language name.",
"keywords": [
"639",
"iso",
"iso-639",
"lang",
"language",
"laravel"
],
"time": "2017-07-19T15:11:19+00:00"
},
{
"name": "monolog/monolog",
"version": "1.23.0",
@@ -2593,6 +2701,213 @@
],
"time": "2018-03-19T15:50:49+00:00"
},
{
"name": "nette/caching",
"version": "v2.5.8",
"source": {
"type": "git",
"url": "https://github.com/nette/caching.git",
"reference": "7fba7c7ab2585fafb7b31152f2595e1551120555"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/caching/zipball/7fba7c7ab2585fafb7b31152f2595e1551120555",
"reference": "7fba7c7ab2585fafb7b31152f2595e1551120555",
"shasum": ""
},
"require": {
"nette/finder": "^2.2 || ~3.0.0",
"nette/utils": "^2.4 || ~3.0.0",
"php": ">=5.6.0"
},
"conflict": {
"nette/nette": "<2.2"
},
"require-dev": {
"latte/latte": "^2.4",
"nette/di": "^2.4 || ~3.0.0",
"nette/tester": "^2.0",
"tracy/tracy": "^2.4"
},
"suggest": {
"ext-pdo_sqlite": "to use SQLiteStorage or SQLiteJournal"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.5-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "⏱ Nette Caching: library with easy-to-use API and many cache backends.",
"homepage": "https://nette.org",
"keywords": [
"cache",
"journal",
"memcached",
"nette",
"sqlite"
],
"time": "2018-03-21T11:04:32+00:00"
},
{
"name": "nette/finder",
"version": "v2.4.1",
"source": {
"type": "git",
"url": "https://github.com/nette/finder.git",
"reference": "4d43a66d072c57d585bf08a3ef68d3587f7e9547"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/finder/zipball/4d43a66d072c57d585bf08a3ef68d3587f7e9547",
"reference": "4d43a66d072c57d585bf08a3ef68d3587f7e9547",
"shasum": ""
},
"require": {
"nette/utils": "^2.4 || ~3.0.0",
"php": ">=5.6.0"
},
"conflict": {
"nette/nette": "<2.2"
},
"require-dev": {
"nette/tester": "^2.0",
"tracy/tracy": "^2.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "Nette Finder: Files Searching",
"homepage": "https://nette.org",
"time": "2017-07-10T23:47:08+00:00"
},
{
"name": "nette/utils",
"version": "v2.5.1",
"source": {
"type": "git",
"url": "https://github.com/nette/utils.git",
"reference": "8a85ce76298c8a8941f912b8fa3ee93ca17d2ebc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/utils/zipball/8a85ce76298c8a8941f912b8fa3ee93ca17d2ebc",
"reference": "8a85ce76298c8a8941f912b8fa3ee93ca17d2ebc",
"shasum": ""
},
"require": {
"php": ">=5.6.0"
},
"conflict": {
"nette/nette": "<2.2"
},
"require-dev": {
"nette/tester": "~2.0",
"tracy/tracy": "^2.3"
},
"suggest": {
"ext-gd": "to use Image",
"ext-iconv": "to use Strings::webalize() and toAscii()",
"ext-intl": "for script transliteration in Strings::webalize() and toAscii()",
"ext-json": "to use Nette\\Utils\\Json",
"ext-mbstring": "to use Strings::lower() etc...",
"ext-xml": "to use Strings::length() etc. when mbstring is not available"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.5-dev"
}
},
"autoload": {
"classmap": [
"src/"
],
"files": [
"src/loader.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.",
"homepage": "https://nette.org",
"keywords": [
"array",
"core",
"datetime",
"images",
"json",
"nette",
"paginator",
"password",
"slugify",
"string",
"unicode",
"utf-8",
"utility",
"validation"
],
"time": "2018-02-19T14:42:42+00:00"
},
{
"name": "paragonie/constant_time_encoding",
"version": "v2.2.2",
@@ -2872,6 +3187,203 @@
],
"time": "2018-04-15T16:55:05+00:00"
},
{
"name": "pragmarx/coollection",
"version": "v0.5.7",
"source": {
"type": "git",
"url": "https://github.com/antonioribeiro/coollection.git",
"reference": "87405353ef1947839c7768c3b024c8ecf923ae9f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/antonioribeiro/coollection/zipball/87405353ef1947839c7768c3b024c8ecf923ae9f",
"reference": "87405353ef1947839c7768c3b024c8ecf923ae9f",
"shasum": ""
},
"require": {
"php": ">=7.0",
"pragmarx/ia-arr": ">=5.5.33",
"pragmarx/ia-collection": ">=5.5.33",
"pragmarx/ia-str": ">=5.5.33"
},
"require-dev": {
"mockery/mockery": "~1.0",
"phpunit/php-timer": ">=1.0|>=2.0",
"phpunit/phpunit": ">=6.0|>=7.0",
"squizlabs/php_codesniffer": "^2.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"PragmaRX\\Coollection\\Package\\": "src/package",
"PragmaRX\\Coollection\\Tests\\": "tests",
"IlluminateExtracted\\": "src/package/Support/IlluminateExtracted",
"IlluminateExtracted\\Tests\\": "tests/IlluminateExtracted"
},
"files": [
"src/package/Support/helpers.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Antonio Carlos Ribeiro",
"email": "acr@antoniocarlosribeiro.com",
"homepage": "https://antoniocarlosribeiro.com",
"role": "Creator"
}
],
"description": "Laravel Illuminate collection with objectified properties",
"homepage": "https://github.com/antonioribeiro/coollection",
"keywords": [
"collection",
"laravel",
"pragmarx"
],
"time": "2018-02-19T02:50:22+00:00"
},
{
"name": "pragmarx/countries",
"version": "v0.5.8",
"source": {
"type": "git",
"url": "https://github.com/antonioribeiro/countries.git",
"reference": "028b295dbd8b09384956e1c9fdb3e5eccdbae1da"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/antonioribeiro/countries/zipball/028b295dbd8b09384956e1c9fdb3e5eccdbae1da",
"reference": "028b295dbd8b09384956e1c9fdb3e5eccdbae1da",
"shasum": ""
},
"require": {
"colinodell/json5": "^1.0",
"nette/caching": "^2.5",
"php": ">=7.0",
"pragmarx/coollection": "^0.5",
"psr/simple-cache": "^1.0"
},
"require-dev": {
"gasparesganga/php-shapefile": "^2.4",
"phpunit/phpunit": "~6.0|~7.0",
"squizlabs/php_codesniffer": "^2.3"
},
"type": "library",
"autoload": {
"psr-4": {
"PragmaRX\\Countries\\Package\\": "src/package",
"PragmaRX\\Countries\\Update\\": "src/update"
},
"files": [
"src/package/Support/helpers.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Antonio Carlos Ribeiro",
"email": "acr@antoniocarlosribeiro.com",
"role": "Creator"
}
],
"description": "PHP Countries and Currencies",
"keywords": [
"borders",
"cities",
"countries",
"currencies",
"flag",
"geometry",
"states",
"taxes",
"timezones",
"topology"
],
"time": "2018-03-13T16:14:30+00:00"
},
{
"name": "pragmarx/countries-laravel",
"version": "v0.5.2",
"source": {
"type": "git",
"url": "https://github.com/antonioribeiro/countries-laravel.git",
"reference": "822e453d608e289742ecd9c6e1ff7b867df27c0e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/antonioribeiro/countries-laravel/zipball/822e453d608e289742ecd9c6e1ff7b867df27c0e",
"reference": "822e453d608e289742ecd9c6e1ff7b867df27c0e",
"shasum": ""
},
"require": {
"laravel/framework": ">=5.3",
"php": ">=7.0",
"pragmarx/coollection": ">=0.5",
"pragmarx/countries": "^0.5.0",
"psr/simple-cache": "^1.0"
},
"require-dev": {
"colinodell/json5": "^1.0",
"gasparesganga/php-shapefile": "^2.3",
"orchestra/testbench": "~3.0",
"phpunit/phpunit": "~6.0",
"squizlabs/php_codesniffer": "^2.3"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"PragmaRX\\CountriesLaravel\\Package\\ServiceProvider"
],
"aliases": {
"Countries": "PragmaRX\\CountriesLaravel\\Package\\Facade"
}
}
},
"autoload": {
"psr-4": {
"PragmaRX\\CountriesLaravel\\Package\\": "src/package"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Antonio Carlos Ribeiro",
"email": "acr@antoniocarlosribeiro.com",
"role": "Creator"
}
],
"description": "Countries for Laravel",
"keywords": [
"borders",
"cities",
"countries",
"currencies",
"flag",
"geometry",
"laravel",
"states",
"taxes",
"timezones",
"topology"
],
"time": "2018-02-17T16:38:10+00:00"
},
{
"name": "pragmarx/google2fa",
"version": "v3.0.1",
@@ -3004,6 +3516,208 @@
],
"time": "2018-03-08T04:08:14+00:00"
},
{
"name": "pragmarx/ia-arr",
"version": "v5.6.12",
"source": {
"type": "git",
"url": "https://github.com/antonioribeiro/ia-arr.git",
"reference": "de495d1dbd5c1331314e130f4c58f837a6978838"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/antonioribeiro/ia-arr/zipball/de495d1dbd5c1331314e130f4c58f837a6978838",
"reference": "de495d1dbd5c1331314e130f4c58f837a6978838",
"shasum": ""
},
"require": {
"php": ">=7.0",
"symfony/var-dumper": "~3.3|~4.0"
},
"require-dev": {
"mockery/mockery": "~1.0",
"nesbot/carbon": "~1.20",
"phpunit/phpunit": ">=6.0",
"squizlabs/php_codesniffer": "^2.3"
},
"suggest": {
"nesbot/carbon": "Required to use Carbon datetime."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"IlluminateAgnostic\\Arr\\": "src/",
"IlluminateAgnostic\\Arr\\Tests\\": "tests/"
},
"files": [
"src/Support/helpers.php",
"src/Support/alias.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Antonio Carlos Ribeiro",
"email": "acr@antoniocarlosribeiro.com",
"homepage": "https://antoniocarlosribeiro.com",
"role": "Creator"
}
],
"description": "Laravel Illuminate Agnostic Arr",
"homepage": "https://github.com/antonioribeiro/ia-arr",
"keywords": [
"arr",
"array",
"helpers",
"laravel",
"pragmarx"
],
"time": "2018-03-15T21:30:18+00:00"
},
{
"name": "pragmarx/ia-collection",
"version": "v5.6.12",
"source": {
"type": "git",
"url": "https://github.com/antonioribeiro/ia-collection.git",
"reference": "0dfca0b93ea8cd55c067b474f9ab1e0272490e90"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/antonioribeiro/ia-collection/zipball/0dfca0b93ea8cd55c067b474f9ab1e0272490e90",
"reference": "0dfca0b93ea8cd55c067b474f9ab1e0272490e90",
"shasum": ""
},
"require": {
"nesbot/carbon": "~1.22",
"php": ">=7.0",
"ramsey/uuid": "^3.7",
"symfony/var-dumper": "~3.3|~4.0"
},
"require-dev": {
"mockery/mockery": "~1.0",
"moontoast/math": "^1.1",
"phpunit/phpunit": ">=6.0",
"squizlabs/php_codesniffer": "^2.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"IlluminateAgnostic\\Collection\\": "src/",
"IlluminateAgnostic\\Collection\\Tests\\": "tests/"
},
"files": [
"src/Support/helpers.php",
"src/Support/alias.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Antonio Carlos Ribeiro",
"email": "acr@antoniocarlosribeiro.com",
"homepage": "https://antoniocarlosribeiro.com",
"role": "Creator"
}
],
"description": "Laravel Illuminate Agnostic Collection",
"homepage": "https://github.com/antonioribeiro/ia-collection",
"keywords": [
"collection",
"helpers",
"laravel",
"pragmarx"
],
"time": "2018-03-15T21:29:24+00:00"
},
{
"name": "pragmarx/ia-str",
"version": "v5.6.12",
"source": {
"type": "git",
"url": "https://github.com/antonioribeiro/ia-str.git",
"reference": "61eea1881a011202f6cff8370fdf12ea4a42249d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/antonioribeiro/ia-str/zipball/61eea1881a011202f6cff8370fdf12ea4a42249d",
"reference": "61eea1881a011202f6cff8370fdf12ea4a42249d",
"shasum": ""
},
"require": {
"php": ">=7.0"
},
"require-dev": {
"doctrine/inflector": "^1.2",
"mockery/mockery": "~1.0",
"moontoast/math": "^1.1",
"nesbot/carbon": "~1.22",
"phpunit/phpunit": ">=6.0",
"ramsey/uuid": "^3.7",
"squizlabs/php_codesniffer": "^2.3",
"symfony/var-dumper": "~3.3|~4.0"
},
"suggest": {
"doctrine/inflector": "",
"nesbot/carbon": "",
"ramsey/uuid": "",
"symfony/var-dumper": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"IlluminateAgnostic\\Str\\": "src/",
"IlluminateAgnostic\\Str\\Tests\\": "tests/"
},
"files": [
"src/Support/helpers.php",
"src/Support/alias.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Antonio Carlos Ribeiro",
"email": "acr@antoniocarlosribeiro.com",
"homepage": "https://antoniocarlosribeiro.com",
"role": "Creator"
}
],
"description": "Laravel Illuminate Agnostic Str",
"homepage": "https://github.com/antonioribeiro/ia-str",
"keywords": [
"helpers",
"laravel",
"pragmarx",
"str",
"string"
],
"time": "2018-03-15T22:33:25+00:00"
},
{
"name": "pragmarx/random",
"version": "v0.2.2",
+55
View File
@@ -0,0 +1,55 @@
<?php
return [
'cache' => [
'enabled' => true,
'service' => PragmaRX\Countries\Package\Services\Cache::class,
'duration' => 180,
'directory' => sys_get_temp_dir().'/__PRAGMARX_COUNTRIES__/cache',
],
'hydrate' => [
'before' => false,
'after' => false,
'elements' => [
'borders' => false,
'cities' => false,
'currencies' => false,
'flag' => false,
'geometry' => false,
'states' => false,
'taxes' => false,
'timezones' => false,
'timezones_times' => false,
'topology' => false,
],
],
'maps' => [
'lca3' => 'cca3',
'currencies' => 'currency',
],
'validation' => [
'enabled' => false,
'rules' => [
'country' => 'name.common',
'name' => 'name.common',
'nameCommon' => 'name.common',
'cca2',
'cca2',
'cca3',
'ccn3',
'cioc',
'currencies' => 'ISO4217',
'language_short' => 'ISO639_3',
],
],
];
+1 -1
View File
@@ -88,7 +88,7 @@ return [
'time' => true, // Time Datalogger
'memory' => true, // Memory usage
'exceptions' => true, // Exception displayer
'log' => true, // Logs from Monolog (merged in messages if enabled)
'log' => false, // Logs from Monolog (merged in messages if enabled)
'db' => true, // Show database (PDO) queries and bindings
'views' => true, // Views with their data
'route' => true, // Current route information
-7
View File
@@ -129,13 +129,6 @@ $factory->define(App\Offspring::class, function (Faker\Generator $faker) {
];
});
$factory->define(App\Country::class, function (Faker\Generator $faker) {
return [
'iso' => 'ca',
'country' => 'Mali',
];
});
$factory->define(App\Call::class, function (Faker\Generator $faker) {
return [
'account_id' => 1,
@@ -0,0 +1,63 @@
<?php
use App\Address;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class ExternalCountries extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('addresses', function (Blueprint $table) {
$table->char('country', 3)->after('country_id')->nullable();
});
Address::chunk(200, function ($addresses) {
foreach ($addresses as $addresse) {
$iso = DB::table('countries')->where('id', $addresse->country_id)->value('iso');
$addresse->update(['country' => mb_strtoupper(CountriesSeederTable::fixIso($iso))]);
}
});
Schema::table('addresses', function (Blueprint $table) {
$table->dropColumn('country_id');
});
Schema::dropIfExists('countries');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('addresses', function (Blueprint $table) {
$table->integer('country_id')->after('country')->nullable();
});
Schema::create('countries', function (Blueprint $table) {
$table->increments('id');
$table->string('iso');
$table->string('country');
});
(new CountriesSeederTable)->run();
Address::chunk(200, function ($addresses) {
foreach ($addresses as $addresse) {
$id = DB::table('countries')->where('iso', mb_strtolower($addresse->country))->value('id');
$addresse->update(['country_id' => $id]);
}
});
Schema::table('addresses', function (Blueprint $table) {
$table->dropColumn('country');
});
}
}
+10
View File
@@ -257,4 +257,14 @@ class CountriesSeederTable extends Seeder
DB::table('countries')->insert(['iso' => 've', 'country' => 'Venezuela']);
DB::table('countries')->insert(['iso'=>'ae', 'country' => 'United Arab Emirates']);
}
public static function fixIso($iso) {
switch ($iso) {
case 'ct':
// Cyprus
return "CY";
break;
}
return $iso;
}
}
-3
View File
@@ -14,17 +14,14 @@ class DatabaseSeeder extends Seeder
switch (\Illuminate\Support\Facades\App::environment()) {
case 'local':
$this->call(ActivityTypesTableSeeder::class);
$this->call(CountriesSeederTable::class);
$this->call(FakeUserTableSeeder::class);
break;
case 'testing':
$this->call(ActivityTypesTableSeeder::class);
$this->call(CountriesSeederTable::class);
$this->call(FakeUserTableSeeder::class);
break;
case 'production':
$this->call(ActivityTypesTableSeeder::class);
$this->call(CountriesSeederTable::class);
break;
}
}
+13 -1
View File
@@ -4,6 +4,7 @@ use App\Account;
use App\Contact;
use GuzzleHttp\Client;
use Illuminate\Database\Seeder;
use App\Helpers\CountriesHelper;
use Illuminate\Support\Facades\DB;
use Illuminate\Foundation\Testing\WithFaker;
use Symfony\Component\Console\Helper\ProgressBar;
@@ -316,7 +317,7 @@ class FakeContentTableSeeder extends Seeder
if (rand(1, 3) == 1) {
$address = $this->contact->addresses()->create([
'account_id' => $this->contact->account_id,
'country_id' => rand(1, 242),
'country' => $this->getRandomCountry(),
'name' => $this->faker->word,
'street' => (rand(1, 3) == 1) ? $this->faker->streetAddress : null,
'city' => (rand(1, 3) == 1) ? $this->faker->city : null,
@@ -326,6 +327,17 @@ class FakeContentTableSeeder extends Seeder
}
}
private $countries = null;
private function getRandomCountry()
{
if ($this->countries == null) {
$this->countries = CountriesHelper::getAll();
}
return $this->countries->random()->id;
}
public function populateContactFields()
{
if (rand(1, 3) == 1) {
-4
View File
@@ -47,8 +47,4 @@
<env name="QUEUE_DRIVER" value="sync"/>
<env name="APP_DEFAULT_LOCALE" value="en"/>
</php>
<logging>
<log type="coverage-clover" target="./results/coverage.xml"/>
<log type="junit" target="./results/junit.xml"/>
</logging>
</phpunit>
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["webpack:///webpack/bootstrap 057653db6ce7b900eae0"],"names":["parentJsonpFunction","window","chunkIds","moreModules","executeModules","moduleId","chunkId","result","i","resolves","length","installedChunks","push","Object","prototype","hasOwnProperty","call","modules","shift","__webpack_require__","s","installedModules","3","exports","module","l","m","c","d","name","getter","o","defineProperty","configurable","enumerable","get","n","__esModule","object","property","p","oe","err","console","error"],"mappings":"aACA,IAAAA,EAAAC,OAAA,aACAA,OAAA,sBAAAC,EAAAC,EAAAC,GAIA,IADA,IAAAC,EAAAC,EAAAC,EAAAC,EAAA,EAAAC,KACQD,EAAAN,EAAAQ,OAAoBF,IAC5BF,EAAAJ,EAAAM,GACAG,EAAAL,IACAG,EAAAG,KAAAD,EAAAL,GAAA,IAEAK,EAAAL,GAAA,EAEA,IAAAD,KAAAF,EACAU,OAAAC,UAAAC,eAAAC,KAAAb,EAAAE,KACAY,EAAAZ,GAAAF,EAAAE,IAIA,IADAL,KAAAE,EAAAC,EAAAC,GACAK,EAAAC,QACAD,EAAAS,OAAAT,GAEA,GAAAL,EACA,IAAAI,EAAA,EAAYA,EAAAJ,EAAAM,OAA2BF,IACvCD,EAAAY,IAAAC,EAAAhB,EAAAI,IAGA,OAAAD,GAIA,IAAAc,KAGAV,GACAW,EAAA,GAIA,SAAAH,EAAAd,GAGA,GAAAgB,EAAAhB,GACA,OAAAgB,EAAAhB,GAAAkB,QAGA,IAAAC,EAAAH,EAAAhB,IACAG,EAAAH,EACAoB,GAAA,EACAF,YAUA,OANAN,EAAAZ,GAAAW,KAAAQ,EAAAD,QAAAC,IAAAD,QAAAJ,GAGAK,EAAAC,GAAA,EAGAD,EAAAD,QAKAJ,EAAAO,EAAAT,EAGAE,EAAAQ,EAAAN,EAGAF,EAAAS,EAAA,SAAAL,EAAAM,EAAAC,GACAX,EAAAY,EAAAR,EAAAM,IACAhB,OAAAmB,eAAAT,EAAAM,GACAI,cAAA,EACAC,YAAA,EACAC,IAAAL,KAMAX,EAAAiB,EAAA,SAAAZ,GACA,IAAAM,EAAAN,KAAAa,WACA,WAA2B,OAAAb,EAAA,SAC3B,WAAiC,OAAAA,GAEjC,OADAL,EAAAS,EAAAE,EAAA,IAAAA,GACAA,GAIAX,EAAAY,EAAA,SAAAO,EAAAC,GAAsD,OAAA1B,OAAAC,UAAAC,eAAAC,KAAAsB,EAAAC,IAGtDpB,EAAAqB,EAAA,GAGArB,EAAAsB,GAAA,SAAAC,GAA8D,MAApBC,QAAAC,MAAAF,GAAoBA","file":"/js/manifest.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tvar parentJsonpFunction = window[\"webpackJsonp\"];\n \twindow[\"webpackJsonp\"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [], result;\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n \t\tif(executeModules) {\n \t\t\tfor(i=0; i < executeModules.length; i++) {\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = executeModules[i]);\n \t\t\t}\n \t\t}\n \t\treturn result;\n \t};\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// objects to store loaded and loading chunks\n \tvar installedChunks = {\n \t\t3: 0\n \t};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// on error function for async loading\n \t__webpack_require__.oe = function(err) { console.error(err); throw err; };\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 057653db6ce7b900eae0"],"sourceRoot":""}
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,5 +1,5 @@
{
"/js/app.js": "/js/app.js?id=502c761cd44e9353fd28",
"/js/app.js": "/js/app.js?id=f996b0636a63aefa85a5",
"/css/app.css": "/css/app.css?id=1cb0aa6be3149610785a",
"/css/stripe.css": "/css/stripe.css?id=64c68c04c4e475fcc7c6",
"/js/vendor.js": "/js/vendor.js?id=490bf428af4c7224b600",
@@ -76,7 +76,7 @@
<label class="db fw6 lh-copy f6">
{{ $t('people.contact_address_form_country') }}
</label>
<select class="db w-100 h2" v-model="updateForm.country_id">
<select class="db w-100 h2" v-model="updateForm.country">
<option v-for="country in countries" v-bind:value="country.id">
{{ country.country }}
</option>
@@ -135,7 +135,7 @@
<label class="db fw6 lh-copy f6">
{{ $t('people.contact_address_form_country') }}
</label>
<select class="db w-100 h2" v-model="createForm.country_id">
<select class="db w-100 h2" v-model="createForm.country">
<option value="0"></option>
<option v-for="country in countries" v-bind:value="country.id">
{{ country.country }}
@@ -165,7 +165,7 @@
addMode: false,
createForm: {
country_id: 0,
country: 0,
name: '',
street: '',
city: '',
@@ -175,7 +175,7 @@
updateForm: {
id: '',
country_id: 0,
country: 0,
name: '',
street: '',
city: '',
@@ -228,7 +228,7 @@
},
reinitialize() {
this.createForm.country_id = '';
this.createForm.country = '';
this.createForm.name = '';
this.createForm.street = '';
this.createForm.city = '';
@@ -244,7 +244,7 @@
toggleEdit(contactAddress) {
Vue.set(contactAddress, 'edit', !contactAddress.edit);
this.updateForm.id = contactAddress.id;
this.updateForm.country_id = contactAddress.country_id;
this.updateForm.country = contactAddress.country;
this.updateForm.name = contactAddress.name;
this.updateForm.street = contactAddress.street;
this.updateForm.city = contactAddress.city;
+3 -3
View File
@@ -3,8 +3,8 @@
namespace Tests\Feature;
use App\Contact;
use App\Country;
use Tests\FeatureTestCase;
use App\Helpers\CountriesHelper;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class AddressTest extends FeatureTestCase
@@ -35,9 +35,9 @@ class AddressTest extends FeatureTestCase
$response->assertStatus(200);
$countires = Country::orderBy('country')->get();
$countries = CountriesHelper::getAll();
$response->assertSee($countires[0]->country);
$response->assertSee($countries->first()->country);
}
public function test_users_can_get_addresses()
+7 -16
View File
@@ -50,7 +50,7 @@ class AddressTest extends TestCase
public function testGetCountryCodeReturnsStreetWhenDefined()
{
$address = new Address;
$address->country_id = 1;
$address->country = 'US';
$this->assertEquals(
'United States',
@@ -58,38 +58,29 @@ class AddressTest extends TestCase
);
}
public function testGetCountryISOReturnsNullIfISONotFound()
public function testGetCountryCodeReturnsGB()
{
$address = new Address;
$address->country_id = null;
$this->assertNull($address->getCountryISO());
}
public function testGetCountryISOReturnsTheRightISO()
{
$address = new Address;
$address->country_id = 1;
$address->country = 'GB';
$this->assertEquals(
'us',
$address->getCountryISO()
'United Kingdom',
$address->getCountryName()
);
}
public function testGetGoogleMapsAddressReturnsLink()
{
$address = new Address;
$address->country_id = 1;
$address->country = 'US';
$address->name = 'default';
$address->street = '12';
$address->city = 'Scranton';
$address->province = null;
$address->postal_code = '90210';
$address->country_id = 1;
$this->assertEquals(
'https://www.google.ca/maps/place/'.urlencode($address->getFullAddress()),
'https://www.google.com/maps/place/'.urlencode($address->getFullAddress()),
$address->getGoogleMapAddress()
);
}
+36
View File
@@ -0,0 +1,36 @@
<?php
namespace Tests\Unit;
use Tests\FeatureTestCase;
use App\Helpers\CountriesHelper;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class CountriesTest extends FeatureTestCase
{
use DatabaseTransactions;
public function test_all_countries_exist()
{
try {
Schema::create('countries', function ($table) {
$table->increments('id');
$table->string('iso');
$table->string('country');
});
(new \CountriesSeederTable)->run();
foreach (DB::table('countries')->get() as $country) {
$iso = \CountriesSeederTable::fixIso($country->iso);
$cca2 = CountriesHelper::find($iso);
$this->assertNotEmpty($cca2, "Country not found for ".$iso);
}
}
finally {
Schema::dropIfExists('countries');
}
}
}
+1 -2
View File
@@ -5,7 +5,6 @@ namespace Tests\Unit;
use App\User;
use App\Account;
use App\Contact;
use App\Country;
use Mockery as m;
use Tests\TestCase;
use Illuminate\Foundation\Testing\DatabaseTransactions;
@@ -82,7 +81,7 @@ class ImportVCardsTest extends TestCase
'street' => '17 Shakespeare Ave.',
'postal_code' => 'SO17 2HB',
'city' => 'Southampton',
'country_id' => Country::where('country', 'United Kingdom')->first()->id,
'country' => 'GB',
]);
$this->assertDatabaseHas('contact_fields', [