update remove image when delete ListManagement

This commit is contained in:
2020-12-16 11:28:06 +07:00
parent 9bdfb205f6
commit 0095c2c133
2 changed files with 42 additions and 3 deletions

View File

@@ -181,7 +181,12 @@ class ListManagementController extends Controller {
public function actionDelete() {
if (Yii::$app->request->post()) {
$data = Yii::$app->request->post();
$this->findModel($data['id'])->delete();
$model = $this->findModel($data['id']);
$images = json_decode($model->image, true);
foreach ($images as $k => $v) {
unlink("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $v['url']);
}
$model->delete();
file_get_contents("http://localhost:2305/update-feature");
return true;
}
@@ -215,7 +220,17 @@ class ListManagementController extends Controller {
public function actionBatchDelete() {
if (Yii::$app->request->post()) {
$data = Yii::$app->request->post();
ListManagement::deleteAll(["IN", "id", $data['lists']]);
Yii::$app->response->format = "json";
foreach ($data['lists'] as $key => $value) {
$staff = ListManagement::findOne($value);
if ($staff) {
$images = json_decode($staff->image, true);
foreach ($images as $k => $v) {
unlink("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $v['url']);
}
$staff->delete();
}
}
file_get_contents("http://localhost:2305/update-feature");
return true;
}