From 4f41db0bc7e3709fbb1f6b029ff86857b06a4515 Mon Sep 17 00:00:00 2001 From: KSneijders Date: Tue, 19 Nov 2024 12:10:45 +0100 Subject: [PATCH] Added logic to LanguageController to respect Relation MorphMap --- src/Http/Controllers/LanguageController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Http/Controllers/LanguageController.php b/src/Http/Controllers/LanguageController.php index 1f1ec58..f945103 100644 --- a/src/Http/Controllers/LanguageController.php +++ b/src/Http/Controllers/LanguageController.php @@ -24,7 +24,7 @@ public function index(Request $request): RedirectResponse $model->save(); } else { $lang = UserLanguage::query() - ->where('model_type', $request->get('model')) + ->where('model_type', app($request->get('model'))->getMorphClass()) ->where('model_id', $request->get('model_id')) ->first(); @@ -33,7 +33,7 @@ public function index(Request $request): RedirectResponse $lang->save(); } else { UserLanguage::query()->create([ - 'model_type' => $request->get('model'), + 'model_type' => app($request->get('model'))->getMorphClass(), 'model_id' => $request->get('model_id'), 'lang' => $request->get('lang'), ]);