PHP code example of crmleaf / leave-encashment-calculator

1. Go to this page and download the library: Download crmleaf/leave-encashment-calculator 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/ */

    

crmleaf / leave-encashment-calculator example snippets


use Crmleaf\Payroll\Calculators\LeaveEncashmentCalculator;
use Crmleaf\Payroll\Money;

$result = (new LeaveEncashmentCalculator())->calculate(
    averageMonthlySalary: Money::fromRupees(60_000),
    leaveDaysEncashed: 90,
    yearsOfService: 12,
);

echo $result->explain();      // the formula with the real operands in it
echo $result->workings();     // every step, one per line, with its citation
print_r($result->toArray());  // snake_case, ready for JSON

use Crmleaf\Payroll\Calculators\LeaveEncashmentCalculator;

public function show(LeaveEncashmentCalculator $calculator)
{
    return $calculator->calculate(
        averageMonthlySalary: Money::fromRupees(60_000),
        leaveDaysEncashed: 90,
        yearsOfService: 12,
    )->toArray();
}

// config/leave-encashment-calculator.php
'route' => ['enabled' => true, 'prefix' => 'tools'],
bash
php artisan vendor:publish --tag=leave-encashment-calculator-config
bash
php artisan vendor:publish --tag=leave-encashment-calculator-assets