Image for post
Image for post

Why use Location-demographia laravel library

Most of the time when developers such as myself create a system we usually meet this scenario where on sign up or registration, We tend to have a need to ask the user to select a Country, State, and or City. Coding this on every project from scratch can be tiresome and time-wasting.Location-demographia library package comes in to solve such a problem, It's carefully crafted to give you all countries in the world with their respective cities and states.

Let's go over it below

  1. Written in PHP and Works on laravel version 7.1 and above.
  2. Loads countries, cities, and states from https://www.printful.com/docs/countries automatically on running a command.
  3. Comes with migrations and models for ( Country, State, and City).
  4. Comes with various queries.

Installation

You can install the package via composer:

Update your config (for Laravel 5.4 and below)

Add the service provider to the provider's array in config/app.php:

Add the facade to the aliases array in config/app.php:

After you have added the above classes on config/app.php

run the below command to publish config, run migrations, and load data thus ( countries and their states).

If you have the necessary tables already on your database, you can easily run the following command to only load the necessary location data.

Usage

Before you go… Thanks for reading the article! If you enjoyed it, please don’t forget to show your appreciation by clicking 👏 below!

Any questions or comments hit me up on

Mail: epmnzava@gmail.com

Twitter: https://twitter.com/epmnzava

Github: https://github.com/dbrax

Software Engineer and techprenuer with passion of helping entreprenuers and small businesses using Technology

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store