Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Activitylog Laravel Package

spatie/laravel-activitylog

Log user and model activity in Laravel with a simple API. Automatically record Eloquent model events, link actions to subjects and causers, store custom properties, and query a dedicated activity_log table for auditing and history.

View on GitHub
Deep Wiki
Context7

title: Causer Resolver weight: 11

The CauserResolver class handles resolving who caused an activity. It is registered as a scoped binding (per request) in the container.

For most use cases, you should use the Activity facade instead of interacting with CauserResolver directly:

use Spatie\Activitylog\Facades\Activity;

// Scoped causer (recommended)
Activity::defaultCauser($admin, function () {
    // all activities here will have $admin as causer
});

// Global causer
Activity::defaultCauser($admin);

Advanced usage

If you need lower-level control, resolve the CauserResolver from the container:

use Spatie\Activitylog\Support\CauserResolver;

// Custom resolution callback
app(CauserResolver::class)->resolveUsing(function ($subject) {
    return User::find(1);
});

Note: setCauser() takes priority over resolveUsing().

Methods

resolve

public function resolve(Model | int | string | null $subject = null): ?Model;

resolveUsing

public function resolveUsing(Closure $callback): static;

setCauser

public function setCauser(?Model $causer): static;

withCauser

public function withCauser(?Model $causer, Closure $callback): mixed;
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony