Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get list of countries from countries-laravel package #1117

Merged
merged 33 commits into from
May 8, 2018
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
334d971
Get list of countries from countries-laravel package
asbiin Apr 8, 2018
71e18de
Fix StyleCI
asbiin Apr 8, 2018
50e49d9
update
asbiin Apr 9, 2018
ee7a8f4
Merge remote-tracking branch 'origin/master' into countries-list
asbiin Apr 9, 2018
e0ab2da
Update assets
asbiin Apr 9, 2018
39b484e
Improve
asbiin Apr 13, 2018
76a9bb8
Merge remote-tracking branch 'origin/master' into countries-list
asbiin Apr 16, 2018
9bf0d64
Fix StyleCI
asbiin Apr 16, 2018
cc20046
Merge branch 'countries-list' of github.com:monicahq/monica into coun…
asbiin Apr 17, 2018
37c3af9
wip
asbiin Apr 17, 2018
781babd
wip
asbiin Apr 17, 2018
f1678fc
wip
asbiin Apr 18, 2018
5df626f
Fix test
asbiin Apr 18, 2018
5cef406
Merge remote-tracking branch 'origin/master' into countries-list
asbiin Apr 18, 2018
df1dcfe
Fix StyleCI
asbiin Apr 18, 2018
7ff6c96
Fix Sonar
asbiin Apr 18, 2018
8b0641a
Merge remote-tracking branch 'origin/master' into countries-list
asbiin Apr 25, 2018
100ec2a
Fix previous commit
asbiin Apr 25, 2018
2d42c0d
Merge branch 'master' into countries-list
asbiin Apr 25, 2018
715bb1a
Merge remote-tracking branch 'origin/master' into countries-list
asbiin May 2, 2018
ec99b45
Update
asbiin May 7, 2018
5bbd706
Add changelog
asbiin May 7, 2018
7063a03
Merge remote-tracking branch 'origin/master' into countries-list
asbiin May 7, 2018
9292988
fixes
asbiin May 7, 2018
0ecaa38
Set memory limit to 1G
asbiin May 8, 2018
c2b741e
try
asbiin May 8, 2018
866dc76
Try better configuration file
asbiin May 8, 2018
d5fadb9
Fix class
asbiin May 8, 2018
56c0381
fix class name
asbiin May 8, 2018
2baee8c
Use CountriesHelper;
asbiin May 8, 2018
635deb5
Fix psalm
asbiin May 8, 2018
0ecb593
Fix psalm
asbiin May 8, 2018
fabbe84
Merge branch 'master' into countries-list
asbiin May 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve
  • Loading branch information
asbiin committed Apr 13, 2018
commit 39b484ebb3bfddafeeb0fe0c5e0f1b129940a045
34 changes: 30 additions & 4 deletions app/Helpers/CollectionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace App\Helpers;

use Illuminate\Support\Collection;

class CollectionHelper
{
/**
Expand All @@ -12,7 +14,7 @@ class CollectionHelper
* @param bool $descending
* @return static
*/
public static function sortByCollator($collect, $callback)
public static function sortByCollator($collect, $callback, $options = \Collator::SORT_STRING, $descending = false)
{
$results = [];

Expand All @@ -25,8 +27,11 @@ public static function sortByCollator($collect, $callback)
$results[$key] = $callback($value, $key);
}

$collator = \Collator::create(\App::getLocale());
$collator->asort($results, \Collator::SORT_STRING);
// 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
Expand All @@ -35,7 +40,28 @@ public static function sortByCollator($collect, $callback)
$results[$key] = $collect->get($key);
}

return new \Illuminate\Support\Collection($results);
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];
}

/**
Expand Down