Would be interesting + some issues
Would be interesting if you added more methods for list.
For example if i need a method in select field, so that i can get it just by Countries::getForSelect() or by passing which field i want other than fields.
But my issue is bit different, when i dump Countries::getList() i get array with keys and in each array i get a sub array with country data.
But for some idiotic reason if i try to fetch only one field i get that "index" doesn't exist.
looping foreach in foreach, or any other way, simply didn't work.
So i just lost an hour trying to figure it out and it didn't work.
p.s. code in CharifyCountriesTable doesn't work in postgresql!!!
I had the same problem and I modified the file a little bit but nothing "pull request" worth but maybe an idea...
In the vendor/webpatser/laravel-countries/src/Webpatser/Countries/Countries.php
public function getList($sort = null,$output =null)
{
//Get the countries list
$countries = $this->getCountries();
$list = [];
if(!is_null($output)) {
foreach($countries as $country) {
$list[] = $country[$output];
}
}
.... and I get the list like that: Countries::getList('name','name')
gives me exact the items and the index I need. Maybe a push in the right direction.
Questions, when I call the alias "Countries" I get the error: Non-static method Webpatser\Countries\Countries::getList() should not be called statically, assuming $this from incompatible context
<?php namespace Xxx\Http\Controllers\Organisation;
use Xxx\Http\Requests;
use Xxx\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Webpatser\Countries\Countries;
class OrganisationController extends Controller {
public function create()
{
//Get all countries
$countries = Countries::getList();
}
}
I'm having the same issue.