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.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle