laravel-countries icon indicating copy to clipboard operation
laravel-countries copied to clipboard

Would be interesting + some issues

Open nardev opened this issue 11 years ago • 3 comments

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!!!

nardev avatar Nov 10 '14 04:11 nardev

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.

MarekMaras avatar Nov 11 '14 16:11 MarekMaras

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();
   }
}

ssheduardo avatar Mar 31 '15 12:03 ssheduardo

I'm having the same issue.

TwilightDuck avatar Jan 10 '19 10:01 TwilightDuck