Skip to content

Commit 0e00fe7

Browse files
freekmurzeclaude
andauthored
v5: PHP 8.4+, Laravel 11+, modernized API (#1452)
* Implement v5: require PHP 8.4+/Laravel 11+, modernize API Breaking changes: - Rename activities() to activitiesAsSubject(), actions() to activitiesAsCauser() - Add HasActivity trait that combines LogsActivity + CausesActivity - Rename ActivityLogStatus to ActivitylogStatus (consistent casing) - Rename dontSubmitEmptyLogs() to dontLogEmptyChanges() - Rename withoutLogs() to withoutLogging() - Make getActivitylogOptions() optional (defaults to LogOptions::defaults()) - Require PHP 8.4+ and Laravel 11+ - Consolidate 3 migrations into single migration New features: - ActivityEvent enum (Created, Updated, Deleted, Restored) - CauserResolver::withCauser() for scoped causer overrides - Global default_except_attributes config option - LogOptions serialization safety (strips closures) - Boost v2 guidelines file Modernization: - Use Str::uuid() instead of ramsey/uuid - Use array_find() (PHP 8.4) instead of Arr::first() - Casts as methods on Activity model - Strict comparisons, short nullable notation, typed parameters Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Fix styling * Update documentation for v5 - Update version references from v4 to v5 - Update requirements to PHP 8.4+ and Laravel 11+ - Document optional getActivitylogOptions() (no config needed for basic usage) - Document HasActivity trait combining LogsActivity and CausesActivity - Document ActivityEvent enum - Document CauserResolver::withCauser() for scoped causer overrides - Document default_except_attributes config option - Rename dontSubmitEmptyLogs to dontLogEmptyChanges - Rename withoutLogs to withoutLogging - Rename actions() to activitiesAsCauser() - Update LogOptions API reference with new property/method names Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Drop Pest 3 support, require Pest 4+ Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Use id() shorthand and drop down() method in migration Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Add Activity::defaultCauser() as friendly API for causer resolution Provides a cleaner alternative to using CauserResolver directly: Activity::defaultCauser($admin, fn() => ...); // scoped Activity::defaultCauser($admin); // global Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Add Activity::batch(), remove CauserResolver facade, add UPGRADING.md - Add Activity::batch(fn) as friendly API for batching activities - Remove CauserResolver facade (use Activity::defaultCauser() instead) - Update tests to use CauserResolver class directly - Add v4 to v5 upgrade guide to UPGRADING.md - Update docs for new API surface - Update Boost skill guidelines Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Remove batch system, separate changes from properties Schema changes: - Add attribute_changes column for tracked model changes - Remove batch_uuid column (batch system dropped) - properties column now stores only custom user data Removed: - LogBatch class and LogBatch facade - Activity::batch() method - scopeHasBatch() and scopeForBatch() scopes - Batch-related tests and documentation Renamed: - getExtraProperty() to getProperty() - $activity->changes() to $activity->attribute_changes The properties column is now clean user-owned space. Model attribute tracking (attributes/old) is stored in the dedicated attribute_changes column, eliminating the previous mixing of change data and user data. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Drop Laravel 11, simplify Activity contract - Require Laravel 12+ (for future attribute support) - Remove scopes from Activity contract interface (scopes are a query builder concern, not a model contract concern) - Contract now only requires: subject(), causer(), getProperty() - Custom Activity models no longer need to implement scope methods Note: #[Scope] attribute was investigated but doesn't work with Activity::inLog() static calls (PHP resolves the non-static method directly). Keeping scope prefix convention for now. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Fix docs: Laravel 12+ requirement, attribute_changes references Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Fix CI: update workflow for PHP 8.4+/Laravel 12+, fix class name - Update run-tests.yml matrix to only PHP 8.4/8.5 and Laravel 12/13 - Remove nesbot/carbon constraint from CI - Keep ActivityLogStatus class name (php-cs-fixer enforces it) - Update all references to use ActivityLogStatus consistently - Remove class rename from UPGRADING.md Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Fix README, remove dead CouldNotLogChanges exception - Update README to use getProperty() and attribute_changes - Remove CouldNotLogChanges exception class (never thrown anywhere) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Fix issues found in full review Source: - Fix getProperty() signature mismatch between contract and model - Add withChanges() to Activity facade docblock - Remove duplicate import in ActivitylogServiceProvider Tests: - Remove unused getActivitylogOptions() function in DetectsChangesTest Docs: - Fix typo "litte" in introduction.md - Fix "Pretty Zonda" in logging-model-events.md - Fix key order in introduction.md attribute_changes example Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Fix styling * Fix null safety in getProperty() when properties is null Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Simplify config: rename keys, remove table_name and database_connection Config changes: - Rename env var ACTIVITY_LOGGER_ENABLED to ACTIVITYLOG_ENABLED - Rename delete_records_older_than_days to clean_after_days - Rename subject_returns_soft_deleted_models to include_soft_deleted_subjects - Remove table_name and database_connection options (use custom model instead) - Fix default_except_attributes comment (merged, not overridden) Activity model: - Hardcode $table = 'activity_log' instead of reading from config - Remove constructor that read config (custom table/connection via subclass) Migration: - Hardcode table name instead of reading from config Updated docs, UPGRADING.md, Boost skill, and tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Extract LogActivityAction and CleanActivityLogAction Core operations are now handled by action classes with small overridable protected methods, following the Spatie action pattern. New files: - src/Actions/LogActivityAction.php (resolveDescription, tapActivity, save) - src/Actions/CleanActivityLogAction.php (getCutOffDate, deleteOldActivities) - src/ActivitylogConfig.php (resolves action classes from config, validates they extend base) Both actions are configurable via config/activitylog.php and validated by ActivitylogConfig to ensure custom classes extend the originals. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Use Model type-hint in LogActivityAction instead of Activity contract The action calls save(), accesses attributes, and reads relationships, which are all Model concerns. The Activity contract is too narrow for what the action actually needs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Rename tapActivity to beforeActivityLogged Clearer name that describes when it runs, following Laravel's beforeSave/beforeDelete naming convention. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Replace compound conditions with early returns and small methods Split all && and || conditions into separate if statements with early returns. Extracted helper methods for better readability: - resolveModelForLogging() - determines which model instance to log - shouldLogOnlyDirtyAttributes() - checks if dirty filtering applies - filterDirtyAttributes() - performs the actual dirty diff - isUpdatedEvent() / isDeletedEvent() - named event checks Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Update Boost skill for Enums namespace move Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Move config resolution to ActivitylogConfig, clean up ServiceProvider - Move determineActivityModel/getActivityModelInstance from ServiceProvider to ActivitylogConfig as activityModel()/activityModelInstance() - Extract shared resolveAction() to reduce duplication - ServiceProvider now only handles package registration and bindings Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Move CleanActivitylogCommand to Commands namespace Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Update docs, UPGRADING.md and Boost skill for Support namespace moves Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Remove LoggablePipe contract Pipes for addLogChange() no longer need to implement an interface. Any class with a handle(EventLogBag, Closure) method works (standard Laravel pipeline convention). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * wip * Restructure tests to mirror src directory layout - Support/ -> ActivityLoggerTest, CauserResolverTest - Models/ -> ActivityModelTest, CustomActivityModelTest, CustomDatabaseConnectionActivityModelTest, CustomTableNameModelTest - Commands/ -> CleanActivitylogCommandTest - Traits/ -> LogsActivityTest, CausesActivityTest, DetectsChangesTest Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Extract ChangeDetector, simplify LogsActivity trait Extract pure logic into ChangeDetector support class: - resolveRelatedAttribute() for dot-notation relations - resolveJsonAttribute() for JSON arrow-notation - resolveRelationName() for relation method discovery - filterDirty() and compareValues() for dirty attribute diffing Simplify LogsActivity trait: - attributesToBeLogged() now uses collection pipeline - Split into fillableAttributes(), unguardedAttributes(), explicitAttributes(), excludedAttributes() - buildChanges() replaces attributeValuesToBeLogged() - runChangesPipeline() extracts pipeline logic from boot - shouldSkipEmptyLog() replaces inline check - hasChangedAttributesBeyondIgnored() extracts dirty check - formatAttributeValue() checks casts before dates (fixes custom date cast order) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Update docs for Traits -> Models/Concerns namespace move Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Remove pipe system, use LogActivityAction::transformChanges() instead Removed: - addLogChange() static method - $changesPipes static array - EventLogBag DTO - LoggablePipe contract - runChangesPipeline() method - Pipeline dependency in LogsActivity trait - 3 pipe-related tests - manipulate-changes-array.md docs page - event-bag.md API docs page Users who need to transform the changes array before saving should override transformChanges() on a custom LogActivityAction instead. This is simpler (one method override vs registering pipe classes) and consistent with the action pattern used throughout v5. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Fix CI: regenerate PHPStan baseline, run pint Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * wip * wip * Fix isRestoring() to handle Laravel 13 restore behavior Laravel 13 may touch updated_at during restore, making more than just deleted_at dirty. Instead of checking dirty count === 1, check that deleted_at was previously non-null and is now null. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * wip * v5 * wip * Fix styling * wip * wip * wip * Fix styling * wip * wip --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: freekmurze <483853+freekmurze@users.noreply.github.com>
1 parent 9165cd8 commit 0e00fe7

93 files changed

Lines changed: 3221 additions & 2724 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/composer-normalize.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/phpstan.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: PHPStan
2+
3+
on: [push]
4+
5+
jobs:
6+
phpstan:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v4
12+
13+
- name: Setup PHP
14+
uses: shivammathur/setup-php@v2
15+
with:
16+
php-version: 8.4
17+
18+
- name: Install dependencies
19+
run: composer install --no-interaction --no-progress
20+
21+
- name: Run PHPStan
22+
run: vendor/bin/phpstan analyse
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,25 @@ name: Check & fix styling
33
on: [push]
44

55
jobs:
6-
php-cs-fixer:
6+
pint:
77
runs-on: ubuntu-latest
88

99
steps:
1010
- name: Checkout code
11-
uses: actions/checkout@v3
11+
uses: actions/checkout@v4
1212
with:
1313
ref: ${{ github.head_ref }}
1414

15-
- name: Run PHP CS Fixer
16-
uses: docker://oskarstark/php-cs-fixer-ga:2.19.0
15+
- name: Setup PHP
16+
uses: shivammathur/setup-php@v2
1717
with:
18-
args: --config=.php_cs.dist --allow-risky=yes
18+
php-version: 8.4
19+
20+
- name: Install dependencies
21+
run: composer install --no-interaction --no-progress
22+
23+
- name: Run Pint
24+
run: vendor/bin/pint
1925

2026
- name: Commit changes
2127
uses: stefanzweifel/git-auto-commit-action@v5.2.0

.github/workflows/run-tests.yml

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ name: run-tests
33
on:
44
push:
55
pull_request:
6-
schedule:
7-
- cron: '0 0 * * *'
86

97
jobs:
108
test:
@@ -15,26 +13,9 @@ jobs:
1513
strategy:
1614
fail-fast: false
1715
matrix:
18-
php: [8.5, 8.4, 8.3, 8.2, 8.1]
19-
laravel: [^9.0, ^10.0, ^11.0, ^12.0, ^13.0]
16+
php: [8.5, 8.4]
17+
laravel: [^12.0, ^13.0]
2018
dependency-version: [prefer-lowest, prefer-stable]
21-
exclude:
22-
- laravel: ^12.0
23-
php: 8.1
24-
- laravel: ^11.0
25-
php: 8.1
26-
- laravel: ^10.0
27-
php: 8.4
28-
- laravel: ^10.0
29-
php: 8.5
30-
- laravel: ^9.0
31-
php: 8.4
32-
- laravel: ^9.0
33-
php: 8.5
34-
- laravel: ^13.0
35-
php: 8.2
36-
- laravel: ^13.0
37-
php: 8.1
3819

3920
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
4021

@@ -51,7 +32,7 @@ jobs:
5132

5233
- name: Install dependencies
5334
run: |
54-
composer require "laravel/framework:${{ matrix.laravel }}" "nesbot/carbon:>=2.72" --dev --no-interaction --no-update
35+
composer require "laravel/framework:${{ matrix.laravel }}" --dev --no-interaction --no-update
5536
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
5637
5738
- name: Execute tests

.github/workflows/stale-issues.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</div>
1717

1818
The `spatie/laravel-activitylog` package provides easy to use functions to log the activities of the users of your app. It can also automatically log model events.
19-
The Package stores all activity in the `activity_log` table.
19+
The package stores all activity in the `activity_log` table.
2020

2121
Here's a demo of how you can use it:
2222

@@ -43,7 +43,7 @@ $lastLoggedActivity = Activity::all()->last();
4343

4444
$lastLoggedActivity->subject; //returns an instance of an eloquent model
4545
$lastLoggedActivity->causer; //returns an instance of your user model
46-
$lastLoggedActivity->getExtraProperty('customProperty'); //returns 'customValue'
46+
$lastLoggedActivity->getProperty('customProperty'); //returns 'customValue'
4747
$lastLoggedActivity->description; //returns 'Look, I logged something'
4848
```
4949

@@ -60,17 +60,17 @@ $activity->description; //returns 'updated'
6060
$activity->subject; //returns the instance of NewsItem that was saved
6161
```
6262

63-
Calling `$activity->changes()` will return this array:
63+
Calling `$activity->attribute_changes` will return this collection:
6464

6565
```php
6666
[
6767
'attributes' => [
6868
'name' => 'updated name',
69-
'text' => 'Lorum',
69+
'text' => 'Lorem',
7070
],
7171
'old' => [
7272
'name' => 'original name',
73-
'text' => 'Lorum',
73+
'text' => 'Lorem',
7474
],
7575
];
7676
```

UPGRADING.md

Lines changed: 158 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,160 @@
1+
## From v4 to v5
2+
3+
```bash
4+
composer require spatie/laravel-activitylog "^5.0.0"
5+
```
6+
7+
### Requirements
8+
9+
v5 requires **PHP 8.4+** and **Laravel 12+**. If you're on older versions, stay on v4.
10+
11+
### Migration
12+
13+
v5 ships a single consolidated migration with a new schema. If you're upgrading from v4, you need to create a migration to:
14+
15+
1. Add the `attribute_changes` column (new, stores tracked model changes)
16+
2. Drop the `batch_uuid` column (batch system removed)
17+
3. Migrate existing change data from `properties` to `attribute_changes`
18+
19+
```php
20+
// Example upgrade migration
21+
Schema::table('activity_log', function (Blueprint $table) {
22+
$table->json('attribute_changes')->nullable()->after('causer_id');
23+
$table->dropColumn('batch_uuid');
24+
});
25+
26+
// Then migrate existing data: move 'attributes' and 'old' from properties to attribute_changes
27+
DB::table('activity_log')->whereNotNull('properties')->eachById(function ($row) {
28+
$properties = json_decode($row->properties, true);
29+
$changes = array_intersect_key($properties, array_flip(['attributes', 'old']));
30+
$remaining = array_diff_key($properties, array_flip(['attributes', 'old']));
31+
32+
DB::table('activity_log')->where('id', $row->id)->update([
33+
'attribute_changes' => empty($changes) ? null : json_encode($changes),
34+
'properties' => empty($remaining) ? null : json_encode($remaining),
35+
]);
36+
});
37+
```
38+
39+
### Schema changes
40+
41+
- **`properties`** column now stores only custom user data (set via `withProperties()`)
42+
- **`attribute_changes`** column (new) stores tracked model changes (`attributes`, `old`)
43+
- **`batch_uuid`** column removed (batch system dropped)
44+
- `getExtraProperty()` renamed to `getProperty()`
45+
- `$activity->changes` / `$activity->changes()` replaced by `$activity->attribute_changes`
46+
47+
### Batch system removed
48+
49+
The `LogBatch` class, `LogBatch` facade, and `Activity::batch()` have been removed. If you need to group activities, use a custom property:
50+
51+
```php
52+
$groupId = Str::uuid();
53+
activity()->withProperty('group', $groupId)->log('first');
54+
Activity::where('properties->group', $groupId)->get();
55+
```
56+
57+
### Renamed methods
58+
59+
| v4 | v5 |
60+
|---|---|
61+
| `$model->activities` (LogsActivity) | `$model->activitiesAsSubject` |
62+
| `$model->actions` (CausesActivity) | `$model->activitiesAsCauser` |
63+
| `$activity->changes()` | `$activity->attribute_changes` |
64+
| `getExtraProperty()` | `getProperty()` |
65+
| `dontSubmitEmptyLogs()` | `dontLogEmptyChanges()` |
66+
| `submitEmptyLogs()` | `logEmptyChanges()` |
67+
| `withoutLogs()` | `withoutLogging()` |
68+
| `CauserResolver::setCauser($model)` | `Activity::defaultCauser($model)` |
69+
| `CauserResolver::withCauser($model, fn)` | `Activity::defaultCauser($model, fn)` |
70+
| `tapActivity($activity, $event)` on models | `beforeActivityLogged($activity, $event)` |
71+
72+
### Namespace changes
73+
74+
Several classes moved to sub-namespaces:
75+
76+
| v4 | v5 |
77+
|---|---|
78+
| `Spatie\Activitylog\LogOptions` | `Spatie\Activitylog\Support\LogOptions` |
79+
| `Spatie\Activitylog\CauserResolver` | `Spatie\Activitylog\Support\CauserResolver` |
80+
| `Spatie\Activitylog\ActivityLogStatus` | `Spatie\Activitylog\Support\ActivityLogStatus` |
81+
| `Spatie\Activitylog\ActivityLogger` | `Spatie\Activitylog\Support\ActivityLogger` |
82+
| `Spatie\Activitylog\PendingActivityLog` | `Spatie\Activitylog\Support\PendingActivityLog` |
83+
| `Spatie\Activitylog\ActivityEvent` | `Spatie\Activitylog\Enums\ActivityEvent` |
84+
| `Spatie\Activitylog\CleanActivitylogCommand` | `Spatie\Activitylog\Commands\CleanActivitylogCommand` |
85+
| `Spatie\Activitylog\Traits\LogsActivity` | `Spatie\Activitylog\Models\Concerns\LogsActivity` |
86+
| `Spatie\Activitylog\Traits\CausesActivity` | `Spatie\Activitylog\Models\Concerns\CausesActivity` |
87+
| `Spatie\Activitylog\Traits\HasActivity` | `Spatie\Activitylog\Models\Concerns\HasActivity` |
88+
89+
### HasActivity trait
90+
91+
v5 reintroduces the `HasActivity` trait. It combines `LogsActivity` and `CausesActivity` and provides an `activities()` convenience method. Use it on models (like User) that both cause and log activities.
92+
93+
### getActivitylogOptions() is now optional
94+
95+
You no longer need to implement `getActivitylogOptions()` on every model. The default logs events (created, updated, deleted) without tracking attribute changes. Override the method only when you need to customize attribute logging.
96+
97+
### CauserResolver facade removed
98+
99+
The `CauserResolver` facade has been removed. Use `Activity::defaultCauser()` instead:
100+
101+
```php
102+
// v4
103+
CauserResolver::setCauser($admin);
104+
CauserResolver::withCauser($admin, fn() => ...);
105+
106+
// v5
107+
Activity::defaultCauser($admin);
108+
Activity::defaultCauser($admin, fn() => ...);
109+
```
110+
111+
The `CauserResolver` class still exists and can be resolved from the container for advanced use cases (custom resolution callbacks).
112+
113+
### ActivityEvent enum
114+
115+
v5 introduces an `ActivityEvent` enum. All methods that accept event names also accept the enum:
116+
117+
```php
118+
use Spatie\Activitylog\Enums\ActivityEvent;
119+
120+
Activity::forEvent(ActivityEvent::Created)->get();
121+
activity()->event(ActivityEvent::Updated)->log('...');
122+
```
123+
124+
Plain strings still work for custom event names.
125+
126+
### Config changes
127+
128+
The config file has been simplified. Republish it or update manually.
129+
130+
**Renamed keys:**
131+
132+
| v4 | v5 |
133+
|---|---|
134+
| `enabled` (env: `ACTIVITY_LOGGER_ENABLED`) | `enabled` (env: `ACTIVITYLOG_ENABLED`) |
135+
| `delete_records_older_than_days` | `clean_after_days` |
136+
| `subject_returns_soft_deleted_models` | `include_soft_deleted_subjects` |
137+
138+
**Removed keys:**
139+
- `table_name` and `database_connection` have been removed. If you need a custom table name or connection, create a custom Activity model and set `$table` / `$connection` on it. Then point `activity_model` to your custom model.
140+
141+
**New keys:**
142+
- `actions.log_activity`: action class for logging (default: `LogActivityAction::class`)
143+
- `actions.clean_log`: action class for cleaning (default: `CleanActivityLogAction::class`)
144+
145+
### Pipe system removed
146+
147+
The `addLogChange()` method, `LoggablePipe` interface, and `EventLogBag` class have been removed. To manipulate the changes array before saving, override `transformChanges()` on a custom `LogActivityAction` instead. See the [customizing actions](/docs/laravel-activitylog/v5/advanced-usage/customizing-actions) documentation.
148+
149+
### Customizable actions
150+
151+
Core operations are now handled by action classes that can be extended and swapped via config. This lets you customize how activities are saved (e.g., queue them) or how old records are cleaned without overriding the entire logger or command.
152+
153+
**New keys:**
154+
- `default_except_attributes`: globally exclude attributes from logging for all models
155+
156+
---
157+
1158
## From v3 to v4
2159

3160
``` bash
@@ -17,7 +174,7 @@ php artisan migrate
17174
- To control what attributes are logged, instead of defining a `$logAttributes` property this is defined in the `getActivitylogOptions()` method using the `logOnly()` method of `LogOptions`.
18175
- The `getDescriptionForEvent()` method is no longer used to customize the description. Instead, use the `setDescriptionForEvent()` method for `LogOptions` class.
19176
- When customizing the log's name instead of defining a `$logName` property, call the `useLogName()` method when configuring the `LogOptions`.
20-
- Instead of the `$ignoreChangedAttributes` property the ` dontLogIfAttributesChangedOnly()` method should be used.
177+
- Instead of the `$ignoreChangedAttributes` property the `dontLogIfAttributesChangedOnly()` method should be used.
21178
- If you only need to log the dirty attributes use `logOnlyDirty()` since the `$logOnlyDirty` property is no longer used.
22179
- For instances where you do not want to store empty log events use `dontSubmitEmptyLogs()` instead of setting `$submitEmptyLogs` to `false`.
23180
- When you use a `*` (wildcard) and want to ignore specific elements use the `dontLogIfAttributesChangedOnly()` method instead of the `$logAttributesToIgnore` property.

composer.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,18 @@
3131
],
3232
"homepage": "https://github.com/spatie/activitylog",
3333
"require": {
34-
"php": "^8.1",
35-
"illuminate/config": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0",
36-
"illuminate/database": "^8.69 || ^9.27 || ^10.0 || ^11.0 || ^12.0 || ^13.0",
37-
"illuminate/support": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0",
34+
"php": "^8.4",
35+
"illuminate/config": "^12.0 || ^13.0",
36+
"illuminate/database": "^12.0 || ^13.0",
37+
"illuminate/support": "^12.0 || ^13.0",
3838
"spatie/laravel-package-tools": "^1.6.3"
3939
},
4040
"require-dev": {
4141
"ext-json": "*",
42-
"orchestra/testbench": "^6.23 || ^7.0 || ^8.0 || ^9.6 || ^10.0 || ^11.0",
43-
"pestphp/pest": "^1.20 || ^2.0 || ^3.0 || ^4.0"
42+
"larastan/larastan": "^3.0",
43+
"laravel/pint": "^1.29",
44+
"orchestra/testbench": "^10.0 || ^11.0",
45+
"pestphp/pest": "^4.0"
4446
},
4547
"minimum-stability": "dev",
4648
"prefer-stable": true,

0 commit comments

Comments
 (0)