I need the best way to detect if a new version has been created or not
right now I do it like this
$currentVersion = $quotation->lastVersion()->first();
$this->updateQuotation($quotation, $data);
$newVersion = $quotation->lastVersion()->first();
if ($currentVersion->id != $newVersion->id) {
// do something
}
But I think we can do it efficiently
I create a helper function for that
public function wasVersioned(): bool
{
$versionableAttributes = $this->getVersionableAttributes($this->getVersionStrategy());
return Arr::hasAny($this->getDirty(), array_keys($versionableAttributes));
}
and i used it like this
$this->updateQuotation($quotation, $data);
if ($quotation->wasVersioned()) {
// do something
}
I need the best way to detect if a new version has been created or not
right now I do it like this
But I think we can do it efficiently
I create a helper function for that
and i used it like this