Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel 11 didnt register activity #1284

Open
MaximilianoHitter opened this issue Mar 16, 2024 · 5 comments
Open

Laravel 11 didnt register activity #1284

MaximilianoHitter opened this issue Mar 16, 2024 · 5 comments
Labels

Comments

@MaximilianoHitter
Copy link

MaximilianoHitter commented Mar 16, 2024

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)

  • PHP: 8.3.3
  • Database: MySQL 8.0
  • Laravel: 11.0.7
  • Package: spatie/activity-log
@seth9009
Copy link

seth9009 commented Apr 6, 2024

got the same problem on Laravel 11

@soccerjf
Copy link

same issue with MySql 5.7.44 PHP 8.2 Laravel 11

@AndreaGero
Copy link

same issue with Laravel 11.16.0 and MSSql

@therajumandapati
Copy link

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
Copy link
Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants