From d2308b0c9789c76d6923e30e295f8f1077d0fdea Mon Sep 17 00:00:00 2001 From: adereksisusanto Date: Tue, 14 May 2024 09:23:03 +0700 Subject: [PATCH] fix dropdown file only source translation --- src/Http/Controllers/SourcePhraseController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Http/Controllers/SourcePhraseController.php b/src/Http/Controllers/SourcePhraseController.php index 82c817d..3f3119d 100644 --- a/src/Http/Controllers/SourcePhraseController.php +++ b/src/Http/Controllers/SourcePhraseController.php @@ -107,11 +107,16 @@ public function edit(Phrase $phrase): Response|RedirectResponse return redirect()->route('ltu.phrases.edit', $phrase->uuid); } + $files = []; + foreach (collect($phrase->where('translation_id', $phrase->translation->id)->get())->unique('translation_file_id') as $value) { + $files[] = TranslationFile::where('id', $value->translation_file_id)->first(); + } + return Inertia::render('source/edit', [ 'phrase' => PhraseResource::make($phrase), 'translation' => TranslationResource::make($phrase->translation), 'source' => TranslationResource::make($phrase->translation), - 'files' => TranslationFileResource::collection(TranslationFile::get()), + 'files' => TranslationFileResource::collection($files), 'similarPhrases' => PhraseResource::collection($phrase->similarPhrases()), ]); }