PHP code example of ojiepermana / laravel

1. Go to this page and download the library: Download ojiepermana/laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ojiepermana / laravel example snippets


format_rupiah(250000); // Rp 250.000

ExcelExportService::exportArray('laporan.xlsx', $data, $headers);

// Format default (tanggal bulan tahun)
tanggal_indo('2026-02-07'); 
// Output: 07 Februari 2026

// Dengan nama hari
tanggal_indo('2026-02-07', 'mf', true); 
// Output: Jumat, 07 Februari 2026

// Dengan waktu
tanggal_indo('2026-02-07 14:30:00', 'mf', false, true); 
// Output: 07 Februari 2026 : 14:30

// Format bulan pendek
tanggal_indo('2026-02-07', 'mh'); 
// Output: 07 Feb 2026

// Menggunakan class
use OjiePermana\Laravel\Helpers\IndonesiaHelper;
IndonesiaHelper::tanggal('2026-02-07', 'mf', true, true);

// Bulan penuh
bulan_indo('mf', 2); // Februari

// Bulan pendek
bulan_indo('mh', 2); // Feb

// Format rupiah
format_uang(1500000); 
// Output: Rp 1.500.000

// Tanpa lambang
format_uang(1500000, 'ya', false); 
// Output: 1.500.000

// Sembunyikan nilai
format_uang(1500000, 'tidak'); 
// Output: rahasia

angka_romawi(12); // XII
angka_romawi(2026); // MMXXVI

terbilang(1500000); 
// Output: satu juta lima ratus ribu

terbilang(2026); 
// Output: dua ribu dua puluh enam

nama_hari('2026-02-07'); // Jumat
nama_hari('2026-01-01'); // Kamis

bulan_tahun_indo('2026-02-07'); // Februari 2026

// Jumlah hari antara dua tanggal
jumlah_hari('2026-02-01', '2026-02-28'); // 27

// Jumlah bulan antara dua tanggal
jumlah_bulan('2026-01-01', '2026-06-30'); // 5

// Minggu keberapa dalam bulan
minggu_ke_bulan('2026-02-07'); // pertama

// Hari terakhir bulan
hari_terakhir_bulan('2026-02-07'); // 2026-02-28

// Hari pertama minggu (Senin)
hari_pertama_minggu('2026-02-07'); // 2026-02-02

// Hari terakhir minggu (Minggu)
hari_terakhir_minggu('2026-02-07'); // 2026-02-08

use OjiePermana\Laravel\Helpers\IndonesiaHelper;

// Contoh penggunaan
IndonesiaHelper::tanggal('2026-02-07', 'mf', true, true);
IndonesiaHelper::uang(1500000);
IndonesiaHelper::terbilang(2026);
IndonesiaHelper::romawi(12);
IndonesiaHelper::nameday('2026-02-07');
IndonesiaHelper::jumlahHari2Tanggal('2026-02-01', '2026-02-28');
// dll.

use OjiePermana\Laravel\Facades\BNI;

BNI::create(trxId: 'INV-001', trxAmount: '150000', billingType: 'c', customerName: 'Budi');
BNI::update(trxId: 'INV-001', trxAmount: '200000', customerName: 'Budi');
BNI::show('INV-001');

use OjiePermana\Laravel\Bank\BNI\Billing\BniBillingClient;

$bni = new BniBillingClient(
    clientId:  env('BNI_BILLING_CLIENT_ID'),
    secretKey: env('BNI_BILLING_SECRET_KEY'),
    prefix:    env('BNI_BILLING_PREFIX'),
    url:       env('BNI_BILLING_URL'),
);

use OjiePermana\Laravel\Bank\BNI\Billing\BniBillingEncryptor;

$hashed = BniBillingEncryptor::encryptPayload($data, $client_id, $secret_key);
$result = BniBillingEncryptor::decryptPayload($hashed_string, $client_id, $secret_key);

use Illuminate\Support\Facades\Storage;
use OjiePermana\Laravel\Facades\GCS;

// Upload file
GCS::putFile('uploads', $request->file('dokumen'));

// URL publik
$url = Storage::disk('gcs')->url('images/foto.jpg');

// Baca, hapus, copy, move
$data = Storage::disk('gcs')->get('documents/laporan.pdf');
Storage::disk('gcs')->delete('temp/file.txt');
Storage::disk('gcs')->copy('original.jpg', 'backup/original.jpg');

// Signed URL untuk file private
$signedUrl = Storage::disk('gcs-private')->getAdapter()->signedUrl('contracts/kontrak.pdf', 3600);

'gcs' => [
    'driver'      => 'gcs',
    'project_id'  => env('GCS_PROJECT_ID'),
    'key_file'    => env('GCS_KEY_FILE'),
    'bucket'      => env('GCS_BUCKET'),
    'path_prefix' => env('GCS_PATH_PREFIX', ''),
    'visibility'  => 'public',
],