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

Undefined index: long #21

Open
Jlomaka opened this issue Jul 30, 2017 · 2 comments
Open

Undefined index: long #21

Jlomaka opened this issue Jul 30, 2017 · 2 comments

Comments

@Jlomaka
Copy link

Jlomaka commented Jul 30, 2017

Good afternoon, when I try to get all the cities on request

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\View;
use MenaraSolutions\Geographer\Earth;
use MenaraSolutions\Geographer\City;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        $city = new City();
        $city = $city->toArray();
        View::share('city', $city);
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

and

    <pre>
    <?php var_dump($city); ?>
    </pre>

Have some error: Undefined index: long
what am I doing wrong?

@dusterio
Copy link
Member

You can't instantiate a city object like this! :) You have to use build() method and pass a city ID (that you can get from GeoIP/GeoNames for example)

@Jlomaka
Copy link
Author

Jlomaka commented Jul 30, 2017

Okay, but I need the whole city, how can I do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants