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

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

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

anouar-touati/algerian-cities-laravel

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

anouar-touati/algerian-cities-laravel 适用场景与选型建议

anouar-touati/algerian-cities-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 298 次下载、GitHub Stars 达 8, 最近一次更新时间为 2023 年 08 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 anouar-touati/algerian-cities-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 anouar-touati/algerian-cities-laravel 我们能提供哪些服务?
定制开发 / 二次开发

基于 anouar-touati/algerian-cities-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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