Я пытался обновить форму, в которой есть ввод файла резюме. Я хочу, чтобы пользователи меняли файл только в том случае, если они допустили ошибку, загрузив неправильное резюме, но страница обновилась, и когда я отлаживаю с помощью dd, я не вижу в своем json ответа на ввод резюме со всеми другими полями, вот мой текущий код
InterviewController.php
public function update(Request $request, $id)
{
// Validate the form data
$request->validate([
'candidat_name' => 'required|string',
'poste' => 'required|string',
'interview_time' => 'required|date_format:H:i',
'interview_date' => 'required|date',
'cv' => 'nullable|file|mimes:pdf,doc,docx|max:2048',
'description' => 'required|string',
]);
// Find the existing Interview model instance
$interview = Interview::findOrFail($id);
// Update interview attributes
$interview->candidat_name = $request->input('candidat_name');
$interview->poste = $request->input('poste');
$interview->interview_time = $request->input('interview_time');
$interview->interview_date = $request->input('interview_date');
$interview->description = $request->input('description');
// Handle file upload if a new CV is provided
if ($request->hasFile('cv')) {
// Delete the existing CV file if it exists
if ($interview->cv) {
Storage::delete('public/' . $interview->cv);
}
$cv = $request->file('cv');
$cvPath = $cv->store('cvs', 'public');
$interview->cv = $cvPath;
} else {
// If no new file is provided, keep the existing file path
$interview->cv = $interview->cv;
}
// Save the updated interview
$interview->save();
// Redirect with a success message
return redirect()->route('interviews.index')->with('success', 'Interview updated successfully.');
}
index.blade.php
Вот моя форма
id }}" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
Modifier Informations
@csrf
@method('PUT')
Candidat
Poste
Sélectionner Poste
@foreach ($jobs as $job)
poste == $job->poste ? 'selected' : '' }}>{{ $job->poste }}
@endforeach
Heure d'entretien
Date d'entretien
Curriculum Vitae
Description
{{ $interview->description }}
@endforeach
Подробнее здесь: https://stackoverflow.com/questions/785 ... ile-for-cv
Форма обновления Laravel 9, содержащая входной файл для резюме ⇐ Php
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Требуется ли составлять резюме, если я использую резюме по сетке поиска?
Anonymous » » в форуме Python - 0 Ответы
- 27 Просмотры
-
Последнее сообщение Anonymous
-