PHP code example of saeid-khaleghi / police-reporter
1. Go to this page and download the library: Download saeid-khaleghi/police-reporter 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/ */
saeid-khaleghi / police-reporter example snippets
use SaeidKhaleghi\PoliceReporter\XMLGenerator;
$transactions = Transaction::all();
$reporter = XMLGenerator::create($transactions)->writeToFile($path);
use SaeidKhaleghi\PoliceReporter\Contracts\Reportable;
class Transaction extends Model implements Reportable
{
public function toReportTransaction(): Url | string | array
{
return (new ReportTransaction($this))->transaction();
}
}
use SaeidKhaleghi\PoliceReporter\Tags\Person;
use SaeidKhaleghi\PoliceReporter\Tags\Signatory;
use SaeidKhaleghi\PoliceReporter\Tags\ToAccount;
use SaeidKhaleghi\PoliceReporter\Tags\FromAccount;
use SaeidKhaleghi\PoliceReporter\Tags\TransactionTo;
use SaeidKhaleghi\PoliceReporter\Tags\TransactionFrom;
use SaeidKhaleghi\PoliceReporter\Tags\Transaction as ReportTransaction;
class PoliceReportTransactionMaker
{
private Transaction $transaction;
public function __construct(Transaction $transaction)
{
$this->transaction = $transaction;
}
public function transactionFrom()
{
return new TransactionFrom('From fund code', 'From country');
}
public function fromAccount()
{
return new FromAccount(env('APP_FORMAL_NAME'), env('APP_INSTITUTION_CODE'), 'Branch', 'Account', 'Account_name');
}
public function accountRelatedPerson()
{
$identification = new PersonIdentification('Type', 'id_number', 'country', 'Expiry date');
$user = new Person('Gender', 'First name', 'Last name', 'Birthdate', 'Passport number', 'Passport Country (Two-Letter Country Code)', $identification);
return new Signatory($user);
}
public function transactionTo()
{
return new TransactionTo('To fund code', 'To country');
}
public function toAccount()
{
return ToAccount::create('Institution name', 'Account', 'Account_name', 'swift');
}
public function transaction()
{
return ReportTransaction::create($this->transfer->reference, $this->transfer->updated_at, $this->transfer->origin_amount)
->addFromMyClient($this->transactionFrom()->addFromAccount($this->fromAccount()->addAccountRelatedPerson($this->accountRelatedPerson())))
->addTransactionTo($this->transactionTo()->addToAccount($this->toAccount()));
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.