Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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๐
- Host: GitHub
- URL: https://github.com/irfaardy/raja-ongkir
- Owner: irfaardy
- License: mit
- Created: 2020-02-21T04:30:39.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-01-21T10:46:40.000Z (about 4 years ago)
- Last Synced: 2024-10-12T11:46:43.877Z (4 months ago)
- Topics: cache, cek-ongkir, city, composer, courier, kirim, laravel, ongkir, ongkos, php, plugin, plugins, province, raja-ongkir, rajaongkir
- Language: PHP
- Homepage:
- Size: 161 KB
- Stars: 13
- Watchers: 3
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
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)
[![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 runphp 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 Requestif 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/newJika anda menemukan bug atau error silahkan posting disini https://github.com/irfaardy/raja-ongkir/issues agar dapat diperbaiki bersama-sama.
***