Search code examples
laravelgoogle-geocoderlaravel-5.6

Find Freelancer By Zip Code Look-up Laravel 5.6


I have an application where I have roles setup through middleware as freelancer, employer, and admin. I would like to find freelancers by a given zip code and find employers by a given zip code, depending on which role is searching for which. Is there a package that can help do this with geocode... Something similar to task rabbit website for example. I have searched on google and refined my search and there is not much on the subject. I know Google has an API that can be used. What is the logic on this and how do I get started. Maybe a good tutorial... thanks


Solution

  • Well you could try using geo code apis

    For example, to lookup zip 77379 use a request like this:

    http://maps.googleapis.com/maps/api/geocode/json?address=77379&sensor=true

    then from the response object take geometry.location

    geometry: {
         bounds: {
            northeast: {
                   lat: 30.088189,
                   lng: -95.47364999999999
            },
           southwest: {
                   lat: 29.9871611,
                   lng: -95.5887879
           }
         },
         location: {
                  lat: 30.0314279,
                  lng: -95.5302337
         },
         location_type: "APPROXIMATE",
         viewport: {
           northeast: {
                   lat: 30.088189,
                   lng: -95.47364999999999
          },
          southwest: {
                  lat: 29.9871611,
                  lng: -95.5887879
         }
       }
     }
    

    and from lat and lng do sql query to find users and filter them by role_id

    hope this will help you.