I am trying to check if value was changed in a Laravel model, isDirty
never executes.
if I remove isDirty
Data Updating is working fine only ìsDirty
is not working.
public function update(TeacherRequest $request, $id)
{
$teacher = Teacher::find($id);
if ($teacher->isDirty($request)) {
$new_data = $teacher->$request;
$old_data = $teacher->getOriginal($request);
return response()->json([
'msg' => $new_data,
'msg' => $old_data
]);
}
}
I tried to check only one column
as well if it was changed.
One Column check:
if ($teacher->isDirty('efirst')) {
$new_data = $teacher->efirst;
$old_data = $teacher->getOriginal('efirst');
return response()->json([
'msg' => $new_data,
'msg' => $old_data
]);
}
efirst
is the name of the first column and input field.
I am getting nothing as output even if I change data.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire