PHP code example of crmleaf / salary-templates

1. Go to this page and download the library: Download crmleaf/salary-templates 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 / salary-templates example snippets


use Crmleaf\Payroll\Calculators\SalaryTemplateBuilder;
use Crmleaf\Payroll\Money;

$result = (new SalaryTemplateBuilder())->calculate(
    template: 'structure',
);

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\SalaryTemplateBuilder;

public function show(SalaryTemplateBuilder $calculator)
{
    return $calculator->calculate(
        template: 'structure',
    )->toArray();
}

// config/salary-templates.php
'route' => ['enabled' => true, 'prefix' => 'tools'],

use Crmleaf\Payroll\Tools\SalaryTemplates\Documents\SalaryTemplateBuilderDocument;

return app(SalaryTemplateBuilderDocument::class)->download($result, 'salary-templates.xlsx');
bash
php artisan vendor:publish --tag=salary-templates-config