From 0809200827f5955c892b858849e94c83f5039d3b Mon Sep 17 00:00:00 2001 From: Julien Nahum Date: Mon, 8 Jan 2024 16:50:22 +0100 Subject: [PATCH] Fix form maxfile size + clean formResource --- app/Http/Resources/FormResource.php | 30 +++-------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/app/Http/Resources/FormResource.php b/app/Http/Resources/FormResource.php index 85f11c2..f75942a 100644 --- a/app/Http/Resources/FormResource.php +++ b/app/Http/Resources/FormResource.php @@ -51,12 +51,9 @@ class FormResource extends JsonResource 'removed_properties' => $this->removed_properties, 'last_edited_human' => $this->updated_at?->diffForHumans(), 'seo_meta' => $this->seo_meta, - 'max_file_size' => $this->max_file_size / 1000000, ] : []; - $baseData = $this->getFilteredFormData(parent::toArray($request), $this->userIsFormOwner()); - - return array_merge($baseData, $ownerData, [ + return array_merge(parent::toArray($request), $ownerData, [ 'is_pro' => $this->workspaceIsPro(), 'workspace_id' => $this->workspace_id, 'workspace' => new WorkspaceResource($this->getWorkspace()), @@ -64,32 +61,11 @@ class FormResource extends JsonResource 'is_password_protected' => false, 'has_password' => $this->has_password, 'max_number_of_submissions_reached' => $this->max_number_of_submissions_reached, - 'form_pending_submission_key' => $this->form_pending_submission_key + 'form_pending_submission_key' => $this->form_pending_submission_key, + 'max_file_size' => $this->max_file_size / 1000000, ]); } - /** - * Filter form data to hide properties from users. - * - For relation fields, hides the relation information - */ - private function getFilteredFormData(array $data, bool $userIsFormOwner) - { - if ($userIsFormOwner) return $data; - - $properties = collect($data['properties'])->map(function($property){ - // Remove database details from relation - if ($property['type'] === 'relation') { - if (isset($property['relation'])) { - unset($property['relation']); - } - } - return $property; - }); - - $data['properties'] = $properties->toArray(); - return $data; - } - public function setCleanings(array $cleanings) { $this->cleanings = $cleanings;