diff --git a/app/Http/Controllers/Api/Client/ActivityLogController.php b/app/Http/Controllers/Api/Client/ActivityLogController.php index 70e1b2393..91b679854 100644 --- a/app/Http/Controllers/Api/Client/ActivityLogController.php +++ b/app/Http/Controllers/Api/Client/ActivityLogController.php @@ -20,6 +20,7 @@ class ActivityLogController extends ClientApiController AllowedFilter::exact('ip'), AllowedFilter::partial('event'), ]) + ->allowedSorts(['timestamp']) ->paginate(min($request->query('per_page', 50), 100)) ->appends($request->query()); diff --git a/app/Models/ActivityLog.php b/app/Models/ActivityLog.php index b914d9513..dbf936a67 100644 --- a/app/Models/ActivityLog.php +++ b/app/Models/ActivityLog.php @@ -73,7 +73,12 @@ class ActivityLog extends Model public function actor(): MorphTo { - return $this->morphTo()->withTrashed(); + $morph = $this->morphTo(); + if (method_exists($morph, 'withTrashed')) { + return $morph->withTrashed(); + } + + return $morph; } public function subjects() diff --git a/app/Models/ActivityLogSubject.php b/app/Models/ActivityLogSubject.php index b1262e392..314776034 100644 --- a/app/Models/ActivityLogSubject.php +++ b/app/Models/ActivityLogSubject.php @@ -35,6 +35,11 @@ class ActivityLogSubject extends Pivot public function subject() { - return $this->morphTo()->withTrashed(); + $morph = $this->morphTo(); + if (method_exists($morph, 'withTrashed')) { + return $morph->withTrashed(); + } + + return $morph; } }