1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Spatie\Activitylog not logging the Models inside nwidart/laravel-modules

Discussão em 'Outras Linguagens' iniciado por Mocha, Outubro 3, 2024 às 10:12.

  1. Mocha

    Mocha Guest

    I'm using spatie/laravel-activitylog to log my models activities,

    also I'm using nwidart/laravel-modules to add modules to my app,

    in my App/Models I have BaseModel that extends Model,

    here is the code of that model

    class BaseModel extends Model
    {
    use HasFactory, SoftDeletes, CascadeSoftDeletes, LogsActivity;

    ...


    protected static $recordEvents = [
    'created',
    'updated',
    'deleted',
    'restored',
    'forceDeleted',
    ];



    protected function getActivitylogOptions(): LogOptions
    {
    $name = Str::afterLast(static::class, '\\');

    return LogOptions::defaults()
    ->useLogName($name)
    ->logOnlyDirty()
    ->logExcept(['pin_code', 'password', 'remember_token', 'token'])
    ->dontSubmitEmptyLogs()
    ->dontLogIfAttributesChangedOnly(['updated_at', 'update_by'])
    ->setDescriptionForEvent(function($eventName) {
    if($eventName == 'forceDeleted') return 'Force Deleted';
    return ucfirst($eventName);
    } );
    }

    }



    for any models in my App/Models

    everything is working fine and all the events are getting recorded perfectlly,

    on the other hand all the models in my modules is not getting recorded even though I'm extending the same BaseModel

    this is one of my models files.

    #[ObservedBy(AuctionObserver::class)]
    class Auction extends BaseModel implements HasMedia
    {
    ...
    }


    I attached image of my project tree[​IMG].

    Continue reading...

Compartilhe esta Página