You can install the package via composer:
composer require didikz/laravel-rajaongkir
You can publish the config file with:
php artisan vendor:publish --provider="Didikz\LaravelRajaongkir\LaravelRajaongkirServiceProvider" --tag="config"
Add api key to your .env
file:
RAJAONGKIR_API_KEY=apikeyfromrajaongkir
use Didikz\LaravelRajaOngkir\Location;
$location = new Location(config('laravel-rajaongkir.api_key');
$location->province();
// or using facade
use Didikz\LaravelRajaongkir\Facade\Location;
$provinces = Location::province();
use Didikz\LaravelRajaOngkir\Location;
$location = new Location(config('laravel-rajaongkir.api_key');
$province = $location->province(1);
// or using facade
use Didikz\LaravelRajaongkir\Facade\Location;
$province = Location::province(1);
use Didikz\LaravelRajaOngkir\Location;
$provinceId = 1;
$location = new Location(config('laravel-rajaongkir.api_key');
$cities = $location->city($provinceId);
// or using facade
use Didikz\LaravelRajaongkir\Facade\Location;
$provinceId = 1;
$cities = Location::city($provinceId);
use Didikz\LaravelRajaOngkir\Location;
$provinceId = 6;
$cityId = 152;
$location = new Location(config('laravel-rajaongkir.api_key');
$city = $location->city($provinceId, $cityId);
// or using facade
use Didikz\LaravelRajaongkir\Facade\Location;
$provinceId = 6;
$cityId = 152;
$city = Location::city($provinceId, $cityId);
Check Available Couriers based on their plan
use Didikz\LaravelRajaOngkir\Cost;
$cost = new Cost(config('laravel-rajaongkir.api_key');
$cost->destination(152)->origin(155)->weight(2000)->courier('jne')->calculate();
// or using facade
use Didikz\LaravelRajaOngkir\Facade\Cost;
$cost = Cost::destination(152)->origin(155)->weight(2000)->courier('jne')->calculate();
./vendor/bin/phpunit
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.