定制 anouar-touati/algerian-cities-laravel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

anouar-touati/algerian-cities-laravel

最新稳定版本:v1.2.1

Composer 安装命令:

composer require anouar-touati/algerian-cities-laravel

包简介

A package to facilitate working with algerian cities dataset in Laravel

README 文档

README

Grew tired of repeating the same step in every project to add address to your forms. I had the same frustration, which why I made this package to get you up and running with just few commands.

Acknowledgment

Dataset was taken from this repo

Status

This package is still under development. Use at your own discretion. You can open an issue for bugs or features you would like to be included in the future.

Instalation

composer require  anouar-touati/algerian-cities-laravel
php artisan migrate
php artisan db:seed --class="AnouarTouati\AlgerianCitiesLaravel\Database\Seeders\AlgerianCitiesSeeder"

If auto discovery does not work for you, add this under providers in config/app.php :

AnouarTouati\AlgerianCitiesLaravel\AlgerianCitiesServiceProvider::class

Usage

API

Call these json endpoints

Verb URI Description
Get /api/algeriancities/wilayas Get all wilayas

response format :

[
    {
        "wilaya_code": 3,
        "wilaya_name": "الأغواط",
        "wilaya_name_ascii": "Laghouat"
    },
    {
        "wilaya_code": 4,
        "wilaya_name": "أم البواقي",
        "wilaya_name_ascii": "Oum El Bouaghi"
    },

]
Verb URI Description
Get /api/algeriancities/dairas/{wilaya} Get all dairas at the specified wilaya code or name (arabic or french)

response format :

[
    {
        "daira_name": "المنيعة",
        "daira_name_ascii": "El Menia"
    },
    {
        "daira_name": "المنصورة",
        "daira_name_ascii": "Mansourah"
    },

]
Verb URI Description
Get /api/algeriancities/communes/{daira} Get all communes at the specified daira name (arabic or french)

response format :

[
    {
        "commune_name": "بئر مراد رايس",
        "commune_name_ascii": "Bir Mourad Rais"
    },
    {
        "commune_name": "بئر خادم",
        "commune_name_ascii": "Birkhadem"
    },

]
Verb URI Description
Get /api/algeriancities/postoffices/{commune} Get all post offices at the specified commune name (arabic or french)

response format :

[
    {
        "post_code": 35000,
        "post_name": "بومرداس - القباضة الرئيسية",
        "post_name_ascii": "Boumerdes",
        "post_address": "بومرداس - حي 408 مسكن",
        "post_address_ascii": "Cité 408 Logements Boumerdes"
    },
    {
        "post_code": 35007,
        "post_name": "بومرداس - فرانتز فانون",
        "post_name_ascii": "Boumerdes Frantz Fanon",
        "post_address": "بومرداس - حي 350 مسكن",
        "post_address_ascii": "Cité 350 Logements Boumerdes"
    },

]

Use through the AlgerianCitiesFacade

you can use the methods that the API controller is built with by including this line to the top of your file :

use AnouarTouati\AlgerianCitiesLaravel\Facades\AlgerianCitiesFacade;

All of these methods return a Collection

Mehod Parameters Description
getAllWilayas() returns all wilayas
getDairasUsingWilayaCode() $wilaya_code get list of dairas using wilaya's code
getDairasUsingWilayaName() $wilaya_name get list of dairas using wilaya's name in arabic or french
getCommunesUsingDairaName() $daira_name get list of communes using daira's name in arabic or french
getPostsUsingCommuneName() $commune_name get list of post offices using commune's name in arabic or french
getAllDairas() get list of all dairas
getAllCommunes() get list of all communes

Built-in address Blade component

You can add this ready to use component to your form which will provide the HTML dropdowns for selecting the address and the logic to populate them.

You can add styling by passing values to the :select_style and :label_style props as shown below.

You also need to have the Blade directive @stack with the word scripts like so @stack('scripts') under the closing body tag if you dont have that already.

Example:

 <form action="/formsubmit" method="get">
        <p>Please fill this form</p>

        <x-algerian-citites-laravel::address 
            {{-- The styles below are hideous xD, they are just for demonstartion purposes --}}
            :select_style="'background:green;color:white;'" 
            :label_style="'display:block;color:blue;'"
            />

        <button type="submit">Submit</button>
</form>

Localization

English, French and Arabic translations are available by default for the address form.

If you want to override the default translations you may do so, publish the file to lang/vendor/algerian-cities-laravel by running the following command:

php artisan vendor:publish --tag=algerian-cities-laravel-localization

统计信息

  • 总下载量: 298
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固