From 6bf5900533fc759be398684287a33c0b3ea761be Mon Sep 17 00:00:00 2001 From: br0kenpixel <23280129+br0kenpixel@users.noreply.github.com> Date: Mon, 3 Nov 2025 12:25:23 +0100 Subject: [PATCH] fix: `name` fields being updated instead of `first_name` and `last_name` --- .../Http/Controllers/CompanyController.php | 7 +++-- .../Controllers/StudentDataController.php | 7 +++-- .../dashboard/admin/companies/edit/[id].vue | 11 +++++-- .../dashboard/admin/students/edit/[id].vue | 30 ++++++++++--------- 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/backend/app/Http/Controllers/CompanyController.php b/backend/app/Http/Controllers/CompanyController.php index f8499d6..7b0222c 100644 --- a/backend/app/Http/Controllers/CompanyController.php +++ b/backend/app/Http/Controllers/CompanyController.php @@ -68,7 +68,8 @@ class CompanyController extends Controller 'address' => ['required', 'string', 'max:500'], 'ico' => ['required', 'integer'], 'hiring' => ['required', 'boolean'], - 'contact.name' => ['required', 'string', 'max:255'], + 'contact.first_name' => ['required', 'string', 'max:255'], + 'contact.last_name' => ['required', 'string', 'max:255'], 'contact.email' => ['required', 'email', 'max:255', 'unique:users,email,' . $company->contact], 'contact.phone' => ['nullable', 'string', 'max:20'], ]); @@ -87,7 +88,9 @@ class CompanyController extends Controller if ($contactPerson) { $contactPerson->update([ - 'name' => $request->contact['name'], + 'first_name' => $request->contact['first_name'], + 'last_name' => $request->contact['last_name'], + 'name' => $request->contact['first_name'] . ' ' . $request->contact['last_name'], 'email' => $request->contact['email'], 'phone' => $request->contact['phone'] ?? null, ]); diff --git a/backend/app/Http/Controllers/StudentDataController.php b/backend/app/Http/Controllers/StudentDataController.php index 1187b0d..0de7529 100644 --- a/backend/app/Http/Controllers/StudentDataController.php +++ b/backend/app/Http/Controllers/StudentDataController.php @@ -84,7 +84,8 @@ class StudentDataController extends Controller // Validácia dát $request->validate([ - 'name' => ['required', 'string', 'max:255'], + 'first_name' => ['required', 'string', 'max:255'], + 'last_name' => ['required', 'string', 'max:255'], 'email' => ['required', 'email', 'max:255', 'unique:users,email,' . $id], 'phone' => ['nullable', 'string', 'max:20'], 'student_data.study_field' => ['nullable', 'string', 'max:255'], @@ -94,7 +95,9 @@ class StudentDataController extends Controller // Aktualizácia User údajov $student->update([ - 'name' => $request->name, + 'name' => $request->first_name . ' ' . $request->last_name, + 'first_name' => $request->first_name, + 'last_name' => $request->last_name, 'email' => $request->email, 'phone' => $request->phone, ]); diff --git a/frontend/app/pages/dashboard/admin/companies/edit/[id].vue b/frontend/app/pages/dashboard/admin/companies/edit/[id].vue index f0cca5c..95462a3 100644 --- a/frontend/app/pages/dashboard/admin/companies/edit/[id].vue +++ b/frontend/app/pages/dashboard/admin/companies/edit/[id].vue @@ -19,7 +19,8 @@ const form = ref({ ico: 0, hiring: false, contact: { - name: '', + first_name: '', + last_name: '', email: '', phone: '' } @@ -34,7 +35,8 @@ watch(data, (newData) => { form.value.address = newData.address; form.value.ico = newData.ico; form.value.hiring = !!newData.hiring; - form.value.contact.name = newData.contact?.name; + form.value.contact.first_name = newData.contact?.first_name; + form.value.contact.last_name = newData.contact?.last_name; form.value.contact.email = newData.contact?.email; form.value.contact.phone = newData.contact?.phone; loading.value = false; @@ -102,7 +104,10 @@ function cancel() {