spatie / laravel-activitylog

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

Laravel 11 didnt register activity #1284

Open MaximilianoHitter opened 8 months ago

MaximilianoHitter commented 8 months ago

Describe the bug Already installed activity log into a laravel 11 new proyect, use the same estructure like i used in a laravel 10 proyect, bue get no errors in laravel log and not even using x-debug.

To Reproduce Install package, generate the following trait

`<?php

namespace App\Models\Traits;

use Spatie\Activitylog\LogOptions;

trait LogsActivity { use \Spatie\Activitylog\Traits\LogsActivity;

public function getDescriptionForEvent(string $eventName): string
{
    $arr = ['updated' => 'actualizado', 'created' => 'creado', 'deleted' => 'eliminado'];
    $rta = $arr[$eventName];

    return "Este modelo ha sido {$rta}";
}

public function getActivitylogOptions(): LogOptions
{
    $config = LogOptions::defaults();
    $config->logOnlyDirty();
    $config->logExcept(['created_at', 'updated_at']);
    $config->logOnly(['*']);

    return $config;
}

} ` And add in models this trait

Expected behavior Get activity when create, update or delete model

Versions (please complete the following information)

seth9009 commented 7 months ago

got the same problem on Laravel 11

soccerjf commented 5 months ago

same issue with MySql 5.7.44 PHP 8.2 Laravel 11

AndreaGero commented 4 months ago

same issue with Laravel 11.16.0 and MSSql

therajumandapati commented 2 months ago

This might be because the shouldLogEvent function in LogsActivity trait is returning false for created and updated events. Is this expected behavior?

if (! in_array($eventName, ['created', 'updated'])) {
            return true;
        }
MaximilianoHitter commented 1 month ago

@therajumandapati sorry for the delay, i havent been watching this post. I dont think that change in the implementation makes any effect, because the deleted event should keep working and when i try it again (a few months ago), goy back to the implementation that spatie recommends in the docs page. I already make some kind of "library" on my own to replicate the operation from activity logs (not all the methods and functions) to move over this.