You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I create a new packing list, 2 activities are logged, one for created and one for updated (which is correct) but the properties of the activities are exactly the same, like it was created 2 times and only the event name was changed.
Expected behavior
Should have 2 activities but the updated one should only have the modification on the application_sap_id attribute.
Furthermore, I really do not want to register the modification of the application_sap_id attribute. So when I change my classes to this
#[ObservedBy(PackingListObserver::class)]
class PackingList extends Model
{
use LogsActivity;
publicfunctiongetActivitylogOptions(): LogOptions
{
return LogOptions::defaults()
->useLogName('dngr-packing-lists')
->logAll()
->logExcept([
'ulid',
'application_sap_id',
'created_at',
'updated_at',
])
->logOnlyDirty()
->dontSubmitEmptyLogs();
}
}
class PackingListObserver
{
publicfunctioncreated(PackingList$packing_list): void
{
$packing_list->disableLogging()->update(['application_sap_id' => "SHP-PL{$packing_list->id}"]);
$packing_list->enableLogging();
}
}
Nothing is registered.
I believe it has something to do with the order the observers are registered to the model, because if I use the old method, everything works fine
class PackingList extends Model
{
use LogsActivity;
protectedstaticfunctionboot()
{
parent::boot();
parent::observe(PackingListObserver::class);
}
publicfunctiongetActivitylogOptions(): LogOptions
{
return LogOptions::defaults()
->useLogName('dngr-packing-lists')
->logAll()
->logExcept([
'ulid',
'application_sap_id',
'created_at',
'updated_at',
])
->logOnlyDirty()
->dontSubmitEmptyLogs();
}
}
class PackingListObserver
{
publicfunctioncreated(PackingList$packing_list): void
{
$packing_list->disableLogging()->update(['application_sap_id' => "SHP-PL{$packing_list->id}"]);
}
}
Versions (please complete the following information)
PHP: 8.2
Database: MySql 8.2
Laravel: 11.23.2
Package: 4.8.0
Additional context
I don't have an issue working with the old method of registering observers, but in case it is deprecated there will be a problem using this package.
The text was updated successfully, but these errors were encountered:
Describe the bug
When there is a model that has an observer defined with the new attribute method, the logging does not behave as it should.
To Reproduce
Create a model with an observer like this
The observer modifies the model after it is created
When I create a new packing list, 2 activities are logged, one for created and one for updated (which is correct) but the properties of the activities are exactly the same, like it was created 2 times and only the event name was changed.
Expected behavior
Should have 2 activities but the updated one should only have the modification on the
application_sap_id
attribute.Furthermore, I really do not want to register the modification of the
application_sap_id
attribute. So when I change my classes to thisNothing is registered.
I believe it has something to do with the order the observers are registered to the model, because if I use the old method, everything works fine
Versions (please complete the following information)
Additional context
I don't have an issue working with the old method of registering observers, but in case it is deprecated there will be a problem using this package.
The text was updated successfully, but these errors were encountered: