Skip to content

didikz/laravel-rajaongkir

Repository files navigation

Laravel Rajaongkir

Latest Stable Version Total Downloads Latest Unstable Version License

alt text

Installation

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

Usage

Get All Provinces

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();

Get Province by Id

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);

Get All Cities by Province Id

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);

Get city

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);

Calculate Cost

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();

Testing

./vendor/bin/phpunit

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.