Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/irfaardy/raja-ongkir

Raja Ongkir Plugin for Laravel Framework 5/6/7 and PHP Native๐Ÿš€
https://github.com/irfaardy/raja-ongkir

cache cek-ongkir city composer courier kirim laravel ongkir ongkos php plugin plugins province raja-ongkir rajaongkir

Last synced: 3 months ago
JSON representation

Raja Ongkir Plugin for Laravel Framework 5/6/7 and PHP Native๐Ÿš€

Awesome Lists containing this project

README

        

# ๐Ÿš€Raja Ongkir Laravel Package

[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/irfaardy/raja-ongkir/badges/quality-score.png?b=master) ](https://scrutinizer-ci.com/g/irfaardy/raja-ongkir/?branch=master)[![Build Status](https://scrutinizer-ci.com/g/irfaardy/raja-ongkir/badges/build.png?b=master)](https://scrutinizer-ci.com/g/irfaardy/raja-ongkir/build-status/master) [![Latest Stable Version](https://poser.pugx.org/irfa/raja-ongkir/v/stable)](https://packagist.org/packages/irfa/raja-ongkir) ![PHP](https://github.com/irfaardy/raja-ongkir/workflows/PHP/badge.svg?branch=master)

Buy Me A Coffee [![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/S6S52P7SN)

Package ini berguna untuk mengecek biaya ongkos kirim dari kurir, package ini dapat digunakan di Laravel 5/6/7 atau PHP Native.
**(untuk saat ini hanya mendukung tipe akun starter)**

๐Ÿ› ๏ธ Installation with Composer

```php
composer require irfa/raja-ongkir
```

>You can get Composer [ here]( https://getcomposer.org/download/)

๐Ÿ› ๏ธ PHP Native Setup

```php
Configuration File

> **Config location :** vendor/irfa/raja-ongkir/config/config.php

```php
'your-account-type',

'api_key' => 'your-api-key',
];
```

> You can get API key in [Raja Ongkir](https://rajaongkir.com/).
Account type supported : starter.

***

๐Ÿ› ๏ธ Laravel Setup

Add to config/app.php

```php
'providers' => [
....
Irfa\RajaOngkir\RajaOngkirServiceProvider::class,
];
```

Add to config/app.php

```php
'aliases' => [
....
'RajaOngkir' => Irfa\RajaOngkir\Facades\Ongkir::class,

],
```

Publish Vendor

```php
php artisan vendor:publish --tag=raja-ongkir
```

Open .env file and add this line

....
RAJAONGKIR_ACCOUNT_TYPE=starter
RAJAONGKIR_API_KEY=your-api-key
RAJAONGKIR_PROV_TABLE=ro_province
RAJAONGKIR_CITY_TABLE=ro_city
RAJAONGKIR_CACHE=database

***

๐Ÿš€ Caching

> Caching is useful for loading city and province faster๐Ÿš€.
You can change cache type in ***config/irfa/rajaongkir.php or project_name/.env***.
**This function currently only supports the Laravel Framework**

**Cache support :** database and file
( if you don't want to use cache you can set it to *null* )

**Migrating table city and provinsi**

> If you want to use database cache, you must run migrate first.

php artisan migrate

Caching Province,Sub-District and City


Open console/cmd and run

php artisan raja-ongkir:cache all

Caching City


Open console/cmd and run

php artisan raja-ongkir:cache city

Caching Province


Open console/cmd and run

php artisan raja-ongkir:cache province

Clear Cache


Open console/cmd and run

php artisan raja-ongkir:cache clear

Refresh Cache


Clear old cache and create latest cache.

Open console/cmd and run

php artisan raja-ongkir:cache refresh

***

๐Ÿ’ป Usage

```php
use RajaOngkir;
```

Retrieve all province

```php
$get = RajaOngkir::province()->get();
foreach($get as $prov)
{
echo $prov->province_id."
"; // value = 1
echo $prov->province."
";// value = Bali
}
```

Search province

```php
$get = RajaOngkir::find(['province_id' => 1])->province()->get();
echo $get->province_id."
"; // value = 1
echo $get->province."
";// value = Bali
```

Retrieve all City

```php
$get = RajaOngkir::city()->get();
foreach($get as $city)
{
echo $city->city_id."
"; // value = 17
echo $city->province_id."
";// value = 1
echo $city->province."
";// value = Bali
echo $city->type."
"; // value = Kabupaten
echo $city->city_name."
"; // value = Badung
echo $city->postal_code."
"; // value = 80351
}
```

Retrieve all city in province

```php
$get = RajaOngkir::find(['province_id' => 1])->city()->get();
foreach($get as $city){
echo $city->city_id."
"; // value = 17
echo $city->province_id."
";// value = 1
echo $city->province."
";// value = Bali
echo $city->type."
"; // value = Kabupaten
echo $city->city_name."
"; // value = Badung
echo $city->postal_code."
"; // value = 80351
}
```

Retrieve courier

```php
$get = RajaOngkir::find(['origin'=>1,'destination'=>2,'weight'=>1000,'courier' => 'jne'])
->courier()->get();
foreach($get as $city)
{
echo $city->code."
"; // value = jne
echo $city->name."
";// value = Jalur Nugraha Ekakurir (JNE)
}
```

Retrieve cost courier

```php
$params = ['origin'=>1,'destination'=>2,'weight'=>1000,'courier' => 'jne'
];
$get = RajaOngkir::find($params)->costDetails()->get();
foreach($get as $cost)
{
echo "Courier Name: ".$cost->service."
";
echo "Description: ".$cost->description."
";
foreach($cost->cost as $detail)
{
echo "Harga: ".$detail->value."
";
echo "Estimasi: ".$detail->etd."
";
echo "Note: ".$detail->note."
";
echo "


";
}
}
```

## How to Contributing?

1. Fork it ()
2. Commit your changes (`git commit -m 'New Feature'`)
3. Push to the branch (`git push origin master`)
4. Create a new Pull Request

if you found bug or error, please post here https://github.com/irfaardy/raja-ongkir/issues so that they can be maintained together.

***
## Bagaimana cara berkontribusi?

1. Lakukan fork di ()
2. Commit perubahan yang anda lakukan (`git commit -m 'Fitur Baru'`)
3. Push ke branch master (`git push origin master`)
4. Buat Pull Request baru

---
## Issue
If you found issues or bug please create new issues here https://github.com/irfaardy/php-gacha/issues/new

Jika anda menemukan bug atau error silahkan posting disini https://github.com/irfaardy/raja-ongkir/issues agar dapat diperbaiki bersama-sama.
***