From d1da46c5aaf2980ef28623f02bdf57bce04da968 Mon Sep 17 00:00:00 2001 From: DaneEveritt Date: Sun, 5 Jun 2022 18:28:08 -0400 Subject: [PATCH] Fix incorrect API definitions --- app/Http/Controllers/Api/Client/ActivityLogController.php | 1 + app/Models/ActivityLog.php | 7 ++++++- app/Models/ActivityLogSubject.php | 7 ++++++- 3 files changed, 13 insertions(+), 2 deletions(-) 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; } }