GithubHelp home page GithubHelp logo

khaledweka / laravel-location Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ichtrojan/laravel-location

0.0 1.0 0.0 1.69 MB

A simple Laravel Package to sort Countries, States and Cities

License: MIT License

PHP 100.00%

laravel-location's Introduction

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

laravel-location's People

Contributors

ichtrojan avatar djunehor avatar cacpmw avatar bosunski avatar chibuzor-in avatar tahrz avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.