<input
type="text"
value="{{$appoin->customer->personal_id}}"
id="customer_id"
class="form-control"
name="customer_id"
/>
Change name="personal_id" to name="customer_id"
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
controller
public function update(Request $request, $id)
{
$appointment = Appointment::findOrFail($id);
try {
$request->validate([
'customer_id' => 'required|exists:customers,personal_id',
'date' => 'required|date',
'clinic' => 'required|string',
'physician' => 'required|string',
'name' => 'required|string',
]);
$appointment->update([
'customer_id' => Customer::where('personal_id', $request->customer_id)->first()->id,
'date' => $request->date,
'note' => $request->note,
'clinic' => $request->clinic,
'physician' => $request->physician,
'name' => $request->name
]);
return redirect()->route('admin.appointment')->with(['success' => 'تم ألتحديث بنجاح']);
} catch (Exception $ex) {
return $ex;
return redirect()->route('admin.appointment')->with(['error' => 'هذا الموعد غير موجود ']);
}
}
blade
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="projectinput1">رقم الهوية </label>
<input type="text" value="{{$appoin->customer->personal_id}}" id="customer_id"
class="form-control" name="personal_id">
@error('personal_id')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
</div>
@mohammadkhallaf the error must be different if you have changed the field name to customer_id?
Aside, this is unnecessary; you have already established from the validation rules that the ID is valid!
$appointment->update([
'customer_id' => Customer::where('personal_id', $request->customer_id)->first()->id,
Please or to participate in this conversation.