From 2e3124f986a4d6f0e02eb9c6fcbe60617d58d2d9 Mon Sep 17 00:00:00 2001 From: Spitfire Date: Wed, 4 Sep 2024 11:13:22 -0600 Subject: [PATCH] Implemented more changes --- app/Services/Entity/RecoverySetupService.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Services/Entity/RecoverySetupService.php b/app/Services/Entity/RecoverySetupService.php index 762877de0..7c6b8ce52 100644 --- a/app/Services/Entity/RecoverySetupService.php +++ b/app/Services/Entity/RecoverySetupService.php @@ -61,6 +61,7 @@ public function search(): array protected function elements(): array { + //Query yields array of objects $elements = DB::select( 'select id, name, deleted_at, deleted_by, type_id, "entity" as type from entities @@ -73,13 +74,16 @@ protected function elements(): array ' order by deleted_at DESC' ); + //We fill the rest of the data needed into the objects $users = $this->campaign->users()->pluck('users.name', 'users.id')->toArray(); foreach ($elements as $key => $element) { $element->deleted_name = $users[$element->deleted_by] ?? 'Unknown'; $element->date = \Carbon\Carbon::createFromTimeStamp(strtotime($element->deleted_at))->diffForHumans(); $element->position = $key; } - //This will cast each object in the array to an array, and the toArray gets you from the collection back to an array. + + //We want to send an array of arrays to JS. + //So this will cast each object in the array to an array, and the toArray gets you from the collection back to an array. return collect($elements)->map(function ($x) { return (array) $x; })->toArray(); }