From 025f306d49d0f8988106c3766e9301ac267c70d2 Mon Sep 17 00:00:00 2001 From: guillaume91 Date: Tue, 21 May 2024 17:06:29 +0200 Subject: [PATCH] wip --- .../app/Livewire/Projects/ProjectManager.php | 16 ++++++++++++---- laravel_app/app/Rules/HarvestFile.php | 3 ++- .../project-manager-properties-modal.blade.php | 4 ++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/laravel_app/app/Livewire/Projects/ProjectManager.php b/laravel_app/app/Livewire/Projects/ProjectManager.php index ffeaf76..12e0ed8 100644 --- a/laravel_app/app/Livewire/Projects/ProjectManager.php +++ b/laravel_app/app/Livewire/Projects/ProjectManager.php @@ -214,7 +214,7 @@ private function validateForm() 'name' => $this->formData['name'], 'pivot_file' => $this->pivotFiles[0] ?? null, 'span_file' => $this->spanFiles[0] ?? null, - 'harvest_data_file' => $this->harvestDataFiles[0] ?? null, + 'harvest_file' => $this->harvestDataFiles[0] ?? null, 'boundingBoxes' => $this->formData['boundingBoxes'], ], [ 'name' => [ @@ -223,9 +223,17 @@ private function validateForm() 'string', 'max:255' ], - 'pivot_file' => ['sometimes'], - 'span_file' => ['sometimes'], - 'harvestDataFile' => ['sometimes',new HarvestFile], + 'pivot_file.extension' => ['sometimes',function ($attribute, $value, $fail) { + if($value != 'json'){ + $fail('Not a json file'); + } + }], + 'span_file' => ['sometimes',function ($attribute, $value, $fail) { + if($value != 'json'){ + $fail('Not a json file'); + } + }], + 'harvest_file' => ['sometimes',new HarvestFile], 'boundingBoxes' => ['required', 'array', 'min:1'], 'boundingBoxes.*.name' => ['required', 'string', 'max:255'], 'boundingBoxes.*.top_left_latitude' => ['required', 'string'], diff --git a/laravel_app/app/Rules/HarvestFile.php b/laravel_app/app/Rules/HarvestFile.php index 7b35310..d2ace6b 100644 --- a/laravel_app/app/Rules/HarvestFile.php +++ b/laravel_app/app/Rules/HarvestFile.php @@ -14,6 +14,7 @@ class HarvestFile implements ValidationRule */ public function validate(string $attribute, mixed $value, Closure $fail): void { - // + $extensions = ['']; + } } diff --git a/laravel_app/resources/views/components/project-manager-properties-modal.blade.php b/laravel_app/resources/views/components/project-manager-properties-modal.blade.php index bfa536b..0b31524 100644 --- a/laravel_app/resources/views/components/project-manager-properties-modal.blade.php +++ b/laravel_app/resources/views/components/project-manager-properties-modal.blade.php @@ -60,9 +60,9 @@ - @error('harvestDataFiles') + @error('harvest_file') {{ $message }} @enderror