dev-master
9999999-devThis package provides the use of raja ongkir API
MIT
The Requires
- php >=5.5.9
- guzzlehttp/guzzle ^6.1
The Development Requires
by Erick Kurniawan
This package provides the use of raja ongkir API
Laravel ongkir provide the use of raja ongkir API in Laravel 5., (*1)
1) To install laravel-ongkir, add the following code to composer.json. Then run composer update
:, (*2)
"bronanza/laravel-ongkir": "dev-master"
2) Open your config/app.php
and add the following code to provider:, (*3)
Bronanza\LaravelOngkir\OngkirServiceProvider::class,
3) Run the command below to publish package config file config/ongkir.php
, (*4)
php artisan vendor:publish
4) You can fill api key
for laravel ongkir in config/ongkir.php
, (*5)
<?php return [ 'api' => 'http://api.rajaongkir.com/starter', 'apiKey' => '12kasjdaksdqpwepqwoepqwoe', 'originCityId' => 151, // Jakarta Barat Based on RajaOngkir API 'couriers' => [ 'jne' => 'JNE', 'tiki' => 'TIKI' ] ];
1) Add the following code in your class file:, (*6)
use Bronanza\LaravelOngkir\Ongkir;
2) Now you can use Laravel-Ongkir:, (*7)
<?php namespace App\Http\Controllers; use App\Http\Controllers\Controller; use Bronanza\LaravelOngkir\Ongkir; class TestController extends Controller { private $laravelOngkir; public function __construct(Ongkir $ongkir) { $this->laravelOngkir = $ongkir; } public function getAllAvailableProvinces() { return $this->laravelOngkir->getAllAvailableProvinces(); } public function getAllAvailableCities() { return $this->laravelOngkir->getAllAvailableCities(); } public function getAvailableCities() { return $this->laravelOngkir->getAvailableCities("5"); } public function getCosts() { return $this->laravelOngkir->getCosts("501", "114", 1700, "jne"); } }
getAllAvailableProvinces()
— use this method to get all available provinces in Indonesia.getAllAvailableCities()
— use this method to get all available cities in Indonesia.getAvailableCities()
— use this method to get available cities for the given province code. This method need 1 paramater:
string
provinceCode
- Province ID in IndonesiagetCosts()
— use this method to get shipment cost based on weight and location. This method need 4 parameter:
string
originId
- city originstring
rajaongkirCityId
- city destinationint
weight
- shipment weight in gramstring
courier
- the available courier code: jne
, pos
, tiki
.This package provides the use of raja ongkir API
MIT