diff --git a/controllers/ListManagementController.php b/controllers/ListManagementController.php index c4d0a513..7f4303c1 100644 --- a/controllers/ListManagementController.php +++ b/controllers/ListManagementController.php @@ -359,18 +359,25 @@ class ListManagementController extends Controller { $ft[] = ["url" => $fileName, "features" => $features['results'][0]['feature']]; } - $model = new ListManagement(); - $model->create([ - 'code' => $data['idStaff'], - 'type' => "wl", - 'name' => $data['name'], - 'image' => json_encode($ft), - 'gender' => "", - 'birthday' => "", - 'telephone' => "", - 'address' => "" - ]); -// file_get_contents("http://localhost:2305/update-feature"); + $model = ListManagement::findOne(['code' => $data['idStaff']]); + if ($model) { + $model->name = $data['name']; + $model->image = json_encode($ft); + $model->last_modified = time(); + $model->save(); + } else { + $model = new ListManagement(); + $model->create([ + 'code' => $data['idStaff'], + 'type' => "wl", + 'name' => $data['name'], + 'image' => json_encode($ft), + 'gender' => "", + 'birthday' => "", + 'telephone' => "", + 'address' => "" + ]); + } return ["status" => true]; } }