unicodeveloper/laravel-ngsc

一个为尼日利亚的州、地方政府和城市提供流畅API的Laravel 5包

1.0.0 2016-01-27 06:23 UTC

This package is auto-updated.

Last update: 2024-09-07 17:11:48 UTC


README

Latest Stable Version License Build Status Quality Score Total Downloads

一个为尼日利亚的州、地方政府和城市提供流畅API的Laravel 5包

安装

需要PHP 5.4+或HHVM 3.3+,以及Composer。

要获取Laravel Ngsc的最新版本,只需将以下行添加到您的composer.json文件的require块中。

"unicodeveloper/laravel-ngsc": "1.0.*"

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

一旦安装了Laravel Ngsc,您需要注册服务提供者。打开config/app.php,并在providers键中添加以下内容。

  • Unicodeveloper\Ngsc\NgscServiceProvider::class

此外,还可以按如下方式注册外观

'aliases' => [
    ...
    'Ngsc' => Unicodeveloper\Ngsc\Facades\NgscFacade::class,
    ...
]

配置

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

$ php artisan vendor:publish --provider="Unicodeveloper\Ngsc\NgscServiceProvider"

用法

您可以通过如下方式在控制器中使用它,使用依赖注入

<?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use Unicodeveloper\Ngsc\Ngsc;
use App\Http\Controllers\Controller;

class StateController extends Controller
{
    protected $ngsc;

    public function __construct(Ngsc $ngsc)
    {
        $this->ngsc = $ngsc;
    }

    /**
     * Get all states
     * @return array
     */
    public function getAllStates()
    {
        return $this->ngsc->getAllStates();
    }
}

您也可以简单地使用如下方式使用出色的外观

/**
 * Gets all the states in Nigeria
 * @return array
 */
Ngsc::getAllStates()

/**
 * Gets the details of just one state, e.g capital, lat, lng
 * @param string  state or state code
 * @return array
 */
Ngsc::getOneState('lagos') OR Ngsc::getOneState('LA')

/**
 * Gets the local government areas of just one state
 * @param string  state or state code
 * @return array
 */
Ngsc::getLGAS('lagos') OR Ngsc::getLGAS('LA')

/**
 * Gets the cities of just one state
 * @param string  state or state code
 * @return array
 */
Ngsc::getCities('lagos') OR Ngsc::getCities('LA')

感谢

非常感谢Devcenter.co团队提供流畅且出色的API

贡献

请随意fork这个包,并通过提交pull request来增强功能。

如何感谢您?

为什么不给github仓库加星?我很乐意得到关注!为什么不将这个仓库的链接分享到Twitter或HackerNews?传播一下!

别忘了关注我的twitter

谢谢!Prosper Otemuyiwa。

许可证

MIT许可证(MIT)。有关更多信息,请参阅许可证文件