wapnen/ghregionsdistrict

Laravel 包用于获取加纳的行政区和地区

dev-master 2018-03-03 18:20 UTC

This package is auto-updated.

Last update: 2024-09-16 03:26:21 UTC


README

Laravel 包用于检索加纳的行政区和地区

安装

需要 PHP 5.4+ 和 Composer

要获取此包的最新版本,请将以下代码块添加到项目 composer.json 文件的 require 块中

"wapnen/GHRegionsDistrict": "1.0.*"

然后您需要运行 composer installcomposer update 来下载它并更新自动加载器。

安装 GhRegionsDistrict 后,您需要注册服务提供者。打开 config/app.php 并将以下内容添加到 providers 键中。

  • Wapnen\GhRegionDistrict\GhRegionDistrictServiceProvider::class,

配置

要开始使用此包,您需要发布所有供应商资产

$ php artisan vendor:publish --provider="Wapnen\GhRegionDistrict\GhRegionDistrictServiceProvider"

现在将数据库迁移到包括地区和地区表

$ php artisan migrate

将以下内容添加到应用程序的 Databaseseeder.php 文件中

        $this->call(RegionTableSeeder::class);
        $this->call(District1TableSeeder::class);
        $this->call(District2TableSeeder::class);	
        $this->call(District3TableSeeder::class);
        $this->call(District4TableSeeder::class);
        $this->call(District5TableSeeder::class);
        $this->call(District6TableSeeder::class);
        $this->call(District7TableSeeder::class);
        $this->call(District8TableSeeder::class);
        $this->call(District9TableSeeder::class);
        $this->call(District10TableSeeder::class);

运行以下命令来自动加载您的文件

composer dump-autoload

最后,运行以下命令来播种到您的数据库

$ php artisan db:seed

用法

检索所有地区

$regions = DB::table('regions')->get();

检索一个地区

$region = DB::table('regions')->where('name', 'Ashanti)->first();

获取特定地区的所有地区

$region = DB::table('regions')->where('name', 'Ashanti)->first();
$districts = DB::table('districts)->where('region_id' , $region->id)->get();

贡献

请随时分叉此包并通过提交拉取请求来增强功能进行贡献。

想联系吗?

您可以在 推特上关注我

许可证

MIT 许可证 (MIT)。