From c4b5148b178257ffb32ed40c43b62207ec5f17fa Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 18 Oct 2024 02:43:49 -0600 Subject: [PATCH] Update AdminReport --- app/Http/Resources/AdminReport.php | 42 ++++++++++++++++++------------ 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/app/Http/Resources/AdminReport.php b/app/Http/Resources/AdminReport.php index c541e58cd..9b9681bcc 100644 --- a/app/Http/Resources/AdminReport.php +++ b/app/Http/Resources/AdminReport.php @@ -2,10 +2,11 @@ namespace App\Http\Resources; -use Illuminate\Http\Request; -use Illuminate\Http\Resources\Json\JsonResource; use App\Services\AccountService; use App\Services\StatusService; +use App\Story; +use Illuminate\Http\Request; +use Illuminate\Http\Resources\Json\JsonResource; class AdminReport extends JsonResource { @@ -16,22 +17,29 @@ class AdminReport extends JsonResource */ public function toArray(Request $request): array { - $res = [ - 'id' => $this->id, - 'reporter' => AccountService::get($this->profile_id, true), - 'type' => $this->type, - 'object_id' => (string) $this->object_id, - 'object_type' => $this->object_type, - 'reported' => AccountService::get($this->reported_profile_id, true), - 'status' => null, - 'reporter_message' => $this->message, - 'admin_seen_at' => $this->admin_seen, - 'created_at' => $this->created_at, - ]; + $res = [ + 'id' => $this->id, + 'reporter' => AccountService::get($this->profile_id, true), + 'type' => $this->type, + 'object_id' => (string) $this->object_id, + 'object_type' => $this->object_type, + 'reported' => AccountService::get($this->reported_profile_id, true), + 'status' => null, + 'reporter_message' => $this->message, + 'admin_seen_at' => $this->admin_seen, + 'created_at' => $this->created_at, + ]; - if($this->object_id && $this->object_type === 'App\Status') { - $res['status'] = StatusService::get($this->object_id, false); - } + if ($this->object_id && $this->object_type === 'App\Status') { + $res['status'] = StatusService::get($this->object_id, false); + } + + if ($this->object_id && $this->object_type === 'App\Story') { + $story = Story::find($this->object_id); + if ($story) { + $res['story'] = $story->toAdminEntity(); + } + } return $res; }