• Stars
    star
    199
  • Rank 195,469 (Top 4 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 5 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple Laravel Package to sort Countries, States and Cities

Laravel Location ▲

hero

Introduction 🖖

This Package offers a simple way to get Countries, Cities and States that you may need for your Application, most especially for dropdown menus.

Step One - Install via Composer 🎼

Require the package via composer into your project

composer require ichtrojan/laravel-location

composer install

Step Two - Publish Configurations ⚙️

Laravel location provides you with an easy way of customizing the tables used for storing Countries, States and Cities. Also, you can customisethe route prefix and middleware. To customize these you need to publish the configuration file. To publish the configuration file, run:

php artisan vendor:publish --tag=laravel-location

You will have config/location.php available for you to edit. The default configurations are:

<?php

return [
    'countries_table' => 'countries',
    'cities_table' => 'cities',
    'states_table' => 'states',
    'routes' => [
        'prefix' => 'location',
        'middleware' => 'web'
    ]
];

You can go ahead and customize the table names, route prefix and middleware as you need before running the Migration.

Step Three - Running Migrations

before you do this make sure your correct Database credentials are set in the .env file

php artisan migrate

migrations

Finally, run the Package seeders

php artisan db:seed --class=Ichtrojan\\Location\\Seeds\\LocationDatabaseSeeder

Usage 🧨

NOTE
The routes below are prefixed with location which is the default configuration set in the config/location.php file. If mofified, replace the prefixin your route with the correct prefix.

Route Description
/location/countries return all countries
/location/country/{id} return a single country by its ID
/location/states return all states
/location/state/{id} return a single state by its ID
/location/states/{countryID} return all states in a country using the country ID
/location/cities return all cities
/location/city/{id} return a single city by its ID
/location/cities/{stateID} return all cities in a state using the state ID

Test

composer test

Contribution

Free for all, if you find an issue with the package or if a group of people somehow created a new country please send in a PR.

Danke Schön

More Repositories

1

nigerian-banks

An API that provides Nigerian bank logos, slug and code.
Go
158
star
2

laravel-otp

OTP generator and validator
PHP
139
star
3

horus

HTTP request logger for Golang
Go
87
star
4

essential-kit

A Boilerplate for all the boring stuffs 🔥😎
JavaScript
50
star
5

fragrance

Fragrance showcase built with Go
Go
49
star
6

laravel-frustration

Frustrate unusual users
PHP
43
star
7

go-location

A simple Go Package to sort Countries, States and Cities
Go
42
star
8

go-todo

A simple todo list application in Golang
Go
37
star
9

thoth

An Error Logger for Go
Go
30
star
10

error-pages

A collection of error pages ⚠️
HTML
27
star
11

payments

Card Payments package
Go
18
star
12

rabbit

Trigger Laravel jobs from Go
Go
17
star
13

deploy_tut

Demo for Logrocket
PHP
15
star
14

MacOS-PHP-Essentials

Set up your PHP Environment for your Mac
Shell
12
star
15

Object-Detection

Real-time Object Detection using Tensorflow and Javascript
JavaScript
12
star
16

node-redis

A CRUD RESTFUL API USING REDIS AS DATABASE
JavaScript
11
star
17

node-rpc-client

A RPC client demo built in NodeJS
JavaScript
10
star
18

go-practice

Go
9
star
19

grpc-server

Go
7
star
20

Barcode-Generator

A Simple Barcode Generator😎🔥
JavaScript
6
star
21

go-docker

Dockerisation of a Golang application
Go
4
star
22

go-package-example

Go Package Example
Go
3
star
23

chow

A CLI tool that converts slack's users JSON export to CSV
Go
3
star
24

Markdown-Editor

A Markdown Editor in VueJS
HTML
3
star
25

go-deck

Go
2
star
26

PHP-Docker

A Docker Boilerplate for PHP Stack
2
star
27

web-server-in-different-languages

Ruby
2
star
28

rails-docker

Ruby on Rails deployment with Docker
Ruby
2
star
29

pop-game

A Bubble Pop game in javascript
JavaScript
2
star
30

twilio-api-project-article-code

PHP
2
star
31

travis-article-sample-project

PHP
2
star
32

estonia

PHP
1
star
33

MongoDB-CRUD

A CRUD RESTFUL API USING MONGODB AS DATABASE
JavaScript
1
star
34

chat-rpc

1
star
35

tonic

Go
1
star
36

laravelng-todo

PHP
1
star
37

Text-Search-Using-Algolia

A text search integration using Algolia and Laravel
PHP
1
star
38

go-mysql

1
star
39

learning-go

1
star
40

probable-parakeet

1
star
41

adefaj

HTML
1
star
42

flask-docker

The Demo Application for DigitalOcean Article
Dockerfile
1
star
43

rails-demo

Ruby
1
star
44

rant-api

Go
1
star
45

carthook

Carthook Interview
PHP
1
star
46

ichtrojan.github.io

VR demo
JavaScript
1
star
47

file-encryption

PHP
1
star
48

allsaints

PHP
1
star
49

go-restful-api

Go
1
star
50

fuckthepolice

Go
1
star