add Exports Invoice Transactions log

This commit is contained in:
edmondlang
2023-07-17 12:26:46 +08:00
parent 46ae50b569
commit 6800f7b2d9
@@ -23,6 +23,7 @@ class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeading
use Exportable;
private $request;
private $counter = 1;
public function __construct(Request $request)
{
@@ -70,6 +71,17 @@ class ExportsInvoiceTransactions implements FromQuery, WithHeadings, WithHeading
{
$row = null;
$logArray = [];
$logArray['counter'] = $this->counter;
$this->counter += 1;
$logArray['system'] = $transaction->system;
$logArray['StatementTransactionOwner_id'] = $transaction->id;
$logArray = json_encode($logArray);
$filePath = storage_path('logs/exports_invoice_transactions.log');
$textToAppend = Carbon::now()->format('[Y-m-d H:i:s]') . ' ' . $logArray . PHP_EOL;
file_put_contents($filePath, $textToAppend, FILE_APPEND);
if($transaction->system == 'EXCHANGE') {
$row = (App()->make($transaction->owner_type))->where('id', $transaction->owner_id)->first();
$company = $row->type === TransactionType::PAYMENT ? $row->owner->company : $row->owner->owner;