Torann / laravel-geoip

Determine the geographical location of website visitors based on their IP addresses.
http://lyften.com/projects/laravel-geoip
BSD 2-Clause "Simplified" License
2.09k stars 372 forks source link

Database caching of MaxMind response, getLatLng() method, and minor clean-up of tabs/spaces #21

Closed stevendesu closed 9 years ago

stevendesu commented 9 years ago
  1. I added an Eloquent model (GeoIPRecord) which stores MaxMind responses. These are valid for 30 days. Optional enhancement in the future: setting this timespan in the config. The purpose of this is to reduce the number of calls made to MaxMind - if someone access the site from the same IP within 30 days and they have lost their session, it will simply pull their location from a local storage instead of burning through API query limits.
  2. I added a second public function: getLatLng(). This returns an array with just the latitude and longitude from the MaxMind response - useful if you plan to do any geography-related math or for working with the Google Maps API
  3. I converted spaces and tabs according to Laravel's Coding Style guidelines (indent with tabs, align with spaces)
vedmaka commented 9 years ago

I think it is not necessary to integrate any kind of caching into this. It is better to keep this module simple and allow developer handle cache tasks: someone may want to use memcached or Redis for it.

stevendesu commented 9 years ago

Makes sense. Not to mention since I have no idea how to use git professionally I just made a pull request from master so any future changes (although mostly bug fixes to my own code) got pulled into the PR on accident.