From fbc48fca5314b11de838578d0184671d51704f20 Mon Sep 17 00:00:00 2001 From: dongpd Date: Thu, 10 Dec 2020 15:19:07 +0700 Subject: [PATCH] =?UTF-8?q?=C4=91i=E1=BB=81u=20ch=E1=BB=89nh=20c=C6=A1=20c?= =?UTF-8?q?h=E1=BA=BF=20ghi=20=C4=91=C3=A8=20th=C3=B4ng=20tin=20khi=20tr?= =?UTF-8?q?=C3=B9ng=20idStaff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/ListManagementController.php | 31 +++++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) 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]; } }