update remove image when delete ListManagement
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user