spatie / laravel-activitylog

Log activity inside your Laravel app
https://docs.spatie.be/laravel-activitylog
MIT License
5.36k stars 714 forks source link

Logs not populated when running db:seed #1190

Closed DiarQoroviqi closed 1 year ago

DiarQoroviqi commented 1 year ago

Describe the bug When running the db:seed command from terminal it does not save the logs, it only save the logs when running a seed for a specific seeder.

To Reproduce I have a model that already uses the trait LogsActivity;

class ContentEntry extends Model
{
    use HasFactory;
    use SoftDeletes;
    use LogsActivity;

    public function getActivitylogOptions(): LogOptions
    {
        return LogOptions::defaults()
            ->logAll()
            ->logOnlyDirty()
            ->dontSubmitEmptyLogs();
    }
}

and a seeder for it ContentEntrySeeder. So when running directly the seeder php artisan db:seed --class=ContentEntrySeeder it works fine and adds the logs, but when running only db:seed(there a other seeders) without specifying the --class it do not add logs for ContentEntry model

Versions (please complete the following information)

geeky3 commented 1 year ago

Hi, @DiarQoroviqi ,

I tried to reproduce the issue with steps mentioned and some simple data but I was not able to reproduce it.

May be you can help me to reproduce it by sharing your use case data.

Following are my system technical specifications:

php => 8.1.18 laravel => 10.10 spatie/laravel-activitylog => "^4.7"

Following is my code, let me know if I am missing anything or may be you can create a repository for demonstrating the issue.

Model

image

Seeder

image image

Running Seeder

image

DB entries

image

spatie-bot commented 1 year ago

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.