-
Is it possible to implement the functionality of grouping the changes, like Did anyone stumble upon similar case? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
After abusing few of my brain cells, I think I found a solution. For anyone who needs this in the future:
And the resolver itself:
Basically, I get the ID (nanoID), of the Though it is not recommended to use |
Beta Was this translation helpful? Give feedback.
-
The problem now is that if you have more model like invoice, you have to add many I solved it another way $myCurrentInvoice; // Invoice model
$myInvoiceItem = new InvoiceItems ();
$myInvoiceItem->sequence_id = $myCurrentInvoice->getKey();
$myInvoiceItem->fill($myInvoiceItemData)->save(); // save works on update/create // maybe another trait
// protected $sequence_id = null; must be added to the model,
// protected $sequence_no = 'invoice_no'; other auxiliar field
// also transformAudit https://laravel-auditing.com/guide/audit-transformation.html
public function transformAudit(array $data): array{
$idKey = empty($this->sequence_id ?? null) ? $this->getKey() : $this->sequence_id;
$noAux = empty($this->sequence_no ?? null) ? '' : $this->{$this->sequence_no};
$data['event_sequence_id'] = return substr(sha1($idKey . ($noAux ?? '')), 0, 16);
return $data;
} |
Beta Was this translation helpful? Give feedback.
After abusing few of my brain cells, I think I found a solution.
For anyone who needs this in the future:
in the
config/audits.php
:And the resolver itself: