You've already forked isop-mirror
fix: name fields being updated instead of first_name and last_name
This commit is contained in:
@@ -68,7 +68,8 @@ class CompanyController extends Controller
|
|||||||
'address' => ['required', 'string', 'max:500'],
|
'address' => ['required', 'string', 'max:500'],
|
||||||
'ico' => ['required', 'integer'],
|
'ico' => ['required', 'integer'],
|
||||||
'hiring' => ['required', 'boolean'],
|
'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.email' => ['required', 'email', 'max:255', 'unique:users,email,' . $company->contact],
|
||||||
'contact.phone' => ['nullable', 'string', 'max:20'],
|
'contact.phone' => ['nullable', 'string', 'max:20'],
|
||||||
]);
|
]);
|
||||||
@@ -87,7 +88,9 @@ class CompanyController extends Controller
|
|||||||
|
|
||||||
if ($contactPerson) {
|
if ($contactPerson) {
|
||||||
$contactPerson->update([
|
$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'],
|
'email' => $request->contact['email'],
|
||||||
'phone' => $request->contact['phone'] ?? null,
|
'phone' => $request->contact['phone'] ?? null,
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -84,7 +84,8 @@ class StudentDataController extends Controller
|
|||||||
|
|
||||||
// Validácia dát
|
// Validácia dát
|
||||||
$request->validate([
|
$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],
|
'email' => ['required', 'email', 'max:255', 'unique:users,email,' . $id],
|
||||||
'phone' => ['nullable', 'string', 'max:20'],
|
'phone' => ['nullable', 'string', 'max:20'],
|
||||||
'student_data.study_field' => ['nullable', 'string', 'max:255'],
|
'student_data.study_field' => ['nullable', 'string', 'max:255'],
|
||||||
@@ -94,7 +95,9 @@ class StudentDataController extends Controller
|
|||||||
|
|
||||||
// Aktualizácia User údajov
|
// Aktualizácia User údajov
|
||||||
$student->update([
|
$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,
|
'email' => $request->email,
|
||||||
'phone' => $request->phone,
|
'phone' => $request->phone,
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ const form = ref({
|
|||||||
ico: 0,
|
ico: 0,
|
||||||
hiring: false,
|
hiring: false,
|
||||||
contact: {
|
contact: {
|
||||||
name: '',
|
first_name: '',
|
||||||
|
last_name: '',
|
||||||
email: '',
|
email: '',
|
||||||
phone: ''
|
phone: ''
|
||||||
}
|
}
|
||||||
@@ -34,7 +35,8 @@ watch(data, (newData) => {
|
|||||||
form.value.address = newData.address;
|
form.value.address = newData.address;
|
||||||
form.value.ico = newData.ico;
|
form.value.ico = newData.ico;
|
||||||
form.value.hiring = !!newData.hiring;
|
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.email = newData.contact?.email;
|
||||||
form.value.contact.phone = newData.contact?.phone;
|
form.value.contact.phone = newData.contact?.phone;
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
@@ -102,7 +104,10 @@ function cancel() {
|
|||||||
|
|
||||||
<h3 class="mb-3">Kontaktná osoba</h3>
|
<h3 class="mb-3">Kontaktná osoba</h3>
|
||||||
|
|
||||||
<v-text-field v-model="form.contact.name" label="Meno a priezvisko" required
|
<v-text-field v-model="form.contact.first_name" label="Meno" required variant="outlined"
|
||||||
|
class="mb-3"></v-text-field>
|
||||||
|
|
||||||
|
<v-text-field v-model="form.contact.last_name" label="Priezvisko" required
|
||||||
variant="outlined" class="mb-3"></v-text-field>
|
variant="outlined" class="mb-3"></v-text-field>
|
||||||
|
|
||||||
<v-text-field v-model="form.contact.email" label="E-mail" type="email" required
|
<v-text-field v-model="form.contact.email" label="E-mail" type="email" required
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ const loading = ref(true);
|
|||||||
const saving = ref(false);
|
const saving = ref(false);
|
||||||
|
|
||||||
const form = ref({
|
const form = ref({
|
||||||
name: '',
|
first_name: '',
|
||||||
|
last_name: '',
|
||||||
email: '',
|
email: '',
|
||||||
phone: '',
|
phone: '',
|
||||||
student_data: {
|
student_data: {
|
||||||
@@ -24,27 +25,25 @@ const form = ref({
|
|||||||
address: ''
|
address: ''
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data } = await useSanctumFetch<User>(`/api/students/${studentId}`);
|
const { data } = await useSanctumFetch<User>(`/api/students/${studentId}`);
|
||||||
|
|
||||||
// Načítanie dát študenta
|
// Načítanie dát študenta
|
||||||
watch(data, (newData) => {
|
watch(data, (newData) => {
|
||||||
if (newData) {
|
if (newData) {
|
||||||
student.value = newData;
|
student.value = newData;
|
||||||
|
|
||||||
form.value = {
|
form.value.first_name = newData.first_name;
|
||||||
name: newData.name || '',
|
form.value.last_name = newData.last_name;
|
||||||
email: newData.email || '',
|
form.value.email = newData.email;
|
||||||
phone: newData.phone || '',
|
form.value.phone = newData.phone;
|
||||||
student_data: {
|
form.value.student_data.study_field = newData.student_data!.study_field;
|
||||||
study_field: newData.student_data?.study_field || '',
|
form.value.student_data.personal_email = newData.student_data!.personal_email;
|
||||||
personal_email: newData.student_data?.personal_email || '',
|
form.value.student_data.address = newData.student_data!.address;
|
||||||
address: newData.student_data?.address || ''
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateTo('/dashboard/admin/students');
|
navigateTo('/dashboard/admin/students');
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
// Uloženie zmien
|
// Uloženie zmien
|
||||||
async function saveChanges() {
|
async function saveChanges() {
|
||||||
@@ -91,7 +90,10 @@ function cancel() {
|
|||||||
<v-card-title>Základné údaje</v-card-title>
|
<v-card-title>Základné údaje</v-card-title>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-form>
|
<v-form>
|
||||||
<v-text-field v-model="form.name" label="Meno a priezvisko" required variant="outlined"
|
<v-text-field v-model="form.first_name" label="Meno" required variant="outlined"
|
||||||
|
class="mb-3"></v-text-field>
|
||||||
|
|
||||||
|
<v-text-field v-model="form.last_name" label="Priezvisko" required variant="outlined"
|
||||||
class="mb-3"></v-text-field>
|
class="mb-3"></v-text-field>
|
||||||
|
|
||||||
<v-text-field v-model="form.email" label="E-mail (prihlasovací)" type="email" required
|
<v-text-field v-model="form.email" label="E-mail (prihlasovací)" type="email" required
|
||||||
|
|||||||
Reference in New Issue
Block a user