My Code is saving data of only one
field(efirst)
if it's changed by isDirty() method, and it'sworking correctly
. how can i achievesame result
if i have 10 fields `without writing each field name.
`
Controller:
public function update(TeacherRequest $request, $id)
{
$teacher = Teacher::find($id);
$teacher->efirst=$request->efirst;
if ($teacher->isDirty()) {
$new_data = $teacher->efirst;
$old_data = $teacher->getOriginal('efirst');
if($teacher->save()){
$teacher->update($request->except('qual_id','id','profile_pic'));
DB::table('teacher_logs')->insert(
['user_id' => $user->id,
'teacher_id' => $teacher->id,
'old_value' => $old_data,
'new_value' => $new_data,
]);
}
}}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire