Skip to content

Support spatie/laravel-activitylog v5 (for javaabu/activitylog v2) #16

Closed

Description

@n4ff4h

From javaabu/activitylog v2 (n4ff4h/activitylog#15), which is built on spatie/laravel-activitylog v5 (its current major; PHP 8.4 / Laravel 12+, the same floor as next-gen).

Permissions' runtime logging already works with v5: LogUserRoleUpdate and LogRolePermissionsUpdate only use activity()->performedOn()->causedBy()->withProperties()->log(), and v5 keeps all of those. Three small things would keep the two packages working together cleanly:

  1. Constraint: require-dev and suggest say spatie/laravel-activitylog: ^4.10. Could they be ^4.10 || ^5.0, with tests on v5? An app with javaabu/activitylog v2 will have v5 installed.
  2. Where the changes go: in v5, model changes live in a separate attribute_changes column (withChanges([...])), and properties holds only custom data. The listeners write attributes/old into properties. activitylog v2 reads properties.attributes/old as a fallback, so nothing breaks. On v5 it would be cleaner to call withChanges() when the method exists (method_exists($log, 'withChanges')) and withProperties() otherwise. Diffs, descriptions and rollback then treat role changes like any model change.
  3. Docs: docs/advanced-usage/activity-log.md imports Spatie\Activitylog\LogOptions and Spatie\Activitylog\Traits\LogsActivity, which are v4 namespaces. In v5 they're Spatie\Activitylog\Support\LogOptions and Spatie\Activitylog\Models\Concerns\LogsActivity. With javaabu/activitylog v2 installed, apps would use Javaabu\Activitylog\Concerns\LogsActivity, whose defaults already skip hidden attributes and timestamps.

activitylog v2 also gives role_updated and permissions_updated their own tags (colour, icon) and readable descriptions, based on the log description, because those logs have no event. If you ever set an event on them (->event('role_updated')), please keep the same names.

Not blocking: activitylog carries on with the fallback.

Activity

  1. added
    next-genNext-gen Javaabu packages
    cross-packageRequested by or affecting another next-gen package
    on Nov 5, 2026
  2. added a commit that references this issue on Nov 5, 2026
    f3fd84f
  3. n4ff4h commented on Nov 5, 2026

    @n4ff4h
    CollaboratorAuthor

    Fixed in f3fd84f on next-gen (PR #15). CI is green; the first run failed with "Could not authenticate against github.com" during the Composer install, and the reruns passed.

    1. Constraint: require-dev and suggest are ^4.10 || ^5.0. This works now because v2 requires javaabu/helpers, which pins javaabu/settings ^1.7 and activitylog 4 (conflicts with settings v2 and activitylog v2) forms#18 dropped javaabu/helpers, which was pinning activitylog 4 through javaabu/settings. CI runs v5.1.3 on the prefer-stable legs and v4.10.1 or v4.12.0 on the prefer-lowest legs. A separate "spatie/laravel-activitylog v4" job runs the latest v4.
    2. Where the changes go: both listeners now go through Listeners\Concerns\LogsChanges. It calls withChanges() when the logger has it (v5), so attribute_changes holds attributes/old and properties stays empty. On v4 it falls back to withProperties(). The tests check v5's attribute_changes and v4's changes(), and on v5 they also check that properties has no changes. The logs still have no event; if one is ever added, it will be role_updated and permissions_updated.
    3. Docs: docs/advanced-usage/activity-log.md uses the v5 imports (Spatie\Activitylog\Models\Concerns\LogsActivity, Spatie\Activitylog\Support\LogOptions), with a note giving the v4 ones. It also has a javaabu/activitylog v2 example using Javaabu\Activitylog\Traits\LogsActivity, the namespace in activitylog's next-gen code, not Concerns as the issue said. Requirements, the upgrade guide, llms.txt and the changelog are updated, and the upgrade guide no longer says forms installs helpers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cross-packageRequested by or affecting another next-gen packagenext-genNext-gen Javaabu packages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions