jamesmills / laravel-timezone

Enable user Timezones in your application.
MIT License
677 stars 91 forks source link

The library does not take the first found IP from 'lookup' config key #78

Open boryn opened 2 years ago

boryn commented 2 years ago

At this moment, the library takes the last found IP from the 'lookup' config key. In documentation there is written "Having in mind when the key is found inside the attribute, that key will be used.", and I believe it should be the first taken.

I'd go with this changes to the lookup() method:

private function lookup($type, $keys)
    {
        $value = null;

        foreach ($keys as $key) {
            if (request()->$type->has($key)) {
                return request()->$type->get($key);
            }
        }

        return $value;
    }
boryn commented 2 years ago

I've prepared a small PR for this: https://github.com/jamesmills/laravel-timezone/pull/79