Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
}
],
"require": {
"php": "^8.0",
"filament/filament": "^4.0|^5.0",
"spatie/laravel-activitylog": "^4.7|^v5.0"
"php": "^8.4",
"filament/filament": "^4.0|5.0",
"spatie/laravel-activitylog": "^5.0"
},
"autoload": {
"psr-4": {
Expand Down
15 changes: 8 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ This package adds a page to the Filament Admin panel to view the activity log ge

## Installation

| Plugin Version | Filament Version | PHP Version |
|----------------|------------------|-------------|
| 0.1.x | 2.x | \> 8.0 |
| 1.x | 3.x | \> 8.1 |
| 2.x | 4.x, 5.x | \> 8.1 |
| Plugin Version | Filament Version | Activitylog | PHP Version |
|----------------|------------------|-------------|-------------|
| 0.1.x | 2.x | 4.x | \> 8.0 |
| 1.x | 3.x | 4.x | \> 8.1 |
| 2.x | 4.x, 5.x | 4.x | \> 8.1 |
| 3.x | 5.x | 5.x | \> 8.4 |

Install via Composer.

Expand All @@ -37,7 +38,7 @@ composer require pxlrbt/filament-activity-log
```

> **Warning**
> This plugin only offers a page to show activities related to your model. You need [`spatie/laravel-activitylog`](https://github.com/spatie/laravel-activitylog) installed and configured for it to work. It is important you are using the `LogsActivity` trait as per [Spatie's docs](https://spatie.be/docs/laravel-activitylog/v4/advanced-usage/logging-model-events) for this work as we use the '->activities()' method of the trait.
> This plugin only offers a page to show activities related to your model. You need [`spatie/laravel-activitylog`](https://github.com/spatie/laravel-activitylog) installed and configured for it to work. It is important you are using the `LogsActivity` trait as per [Spatie's docs](https://spatie.be/docs/laravel-activitylog/v5/advanced-usage/logging-model-events) for this work as we use the `->activitiesAsSubject()` method of the trait.

## Filament v4 Upgrade
Make sure you have a custom theme, add this line and recompile: `@import '../../../../vendor/pxlrbt/filament-activity-log/resources/css/styles.css';`
Expand Down Expand Up @@ -98,7 +99,7 @@ class Order extends Model
}
```

See https://spatie.be/docs/laravel-activitylog/v4/advanced-usage/logging-model-events for more information on the topic.
See https://spatie.be/docs/laravel-activitylog/v5/advanced-usage/logging-model-events for more information on the topic.

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion resources/views/pages/list-activities.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@php
/* @var \Spatie\Activitylog\Models\Activity $activityItem */
$changes = $activityItem->getChangesAttribute();
$changes = $activityItem->attribute_changes ?? collect();
@endphp

<div @class([
Expand Down
10 changes: 5 additions & 5 deletions src/Pages/ListActivities.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getTitle(): string
public function getActivities()
{
return $this->paginateQuery(
$this->record->activities()->with('causer')->latest()->getQuery()
$this->record->activitiesAsSubject()->with('causer')->latest()->getQuery()
);
}

Expand Down Expand Up @@ -105,20 +105,20 @@ public function restoreActivity(int|string $key)
abort(403);
}

$activity = $this->record->activities()
$activity = $this->record->activitiesAsSubject()
->whereKey($key)
->first();

$oldProperties = data_get($activity, 'properties.old');
$oldAttributes = data_get($activity, 'attribute_changes.old');

if ($oldProperties === null) {
if ($oldAttributes === null) {
$this->sendRestoreFailureNotification();

return;
}

try {
$this->record->update($oldProperties);
$this->record->update($oldAttributes);

$this->sendRestoreSuccessNotification();
} catch (Exception $e) {
Expand Down
Loading