1. Go to this page and download the library: Download turahe/ledger 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/ */
turahe / ledger example snippets
use Turahe\Ledger\Models\Invoice;
use Turahe\Ledger\Services\LedgerService;
// Using the model directly
$invoice = Invoice::create([
'model_id' => $user->id,
'model_type' => User::class,
'code' => 'INV-001',
'total_invoice' => 1000.00,
'due_date' => now()->addDays(30),
'status' => 'pending',
'currency' => 'IDR'
]);
// Using the service layer
$ledgerService = app(LedgerService::class);
$invoice = $ledgerService->createInvoice([
'model_id' => $user->id,
'model_type' => User::class,
'code' => 'INV-001',
'total_invoice' => 1000.00,
'due_date' => now()->addDays(30)
]);
use Turahe\Ledger\Models\Invoice;
// Find by code
$invoice = Invoice::byCode('INV-001')->first();
// Find by date range
$recentInvoices = Invoice::byDateRange(
now()->subDays(30),
now()
)->get();
// Find by status
$pendingInvoices = Invoice::byStatus('pending')->get();
// Find by model
$userInvoices = Invoice::byModelType(User::class)
->byModelId($user->id)
->get();
use Turahe\Ledger\Enums\PaymentMethods;
// Get methods by category
$qrisMethods = PaymentMethods::getByCategory('qris');
$eWalletMethods = PaymentMethods::getByCategory('e_wallet');
// Check method properties
if (PaymentMethods::E_WALLET_GOPAY->isDigital()) {
echo "This is a digital payment method";
}
if (PaymentMethods::CASH->isInstant()) {
echo "This is an instant payment method";
}