public function beforeDelete() { if (parent::beforeDelete()) { Product::deleteAll(['cate_id' => $this->id]); return true; } else { return false; } }
public function actionProductnamedelete() { $data = json_decode(file_get_contents("php://input")); $userd = Product::deleteAll('sn=' . $data->id); $arr = array('msg' => "Product Name deleted Successfully !!!", 'error' => ''); $jsn = json_encode($arr); print_r($jsn); }
public function actionDeleteall() { $role = UserRoleDetector::getUserRole(); Yii::$app->response->format = Response::FORMAT_JSON; if ($role != 3 && $role != 4) { echo json_encode(array('status' => 0, 'error_code' => Codes::$UNAUTHORIZED, 'errors' => StatusCodeMessage::$UNAUTHORIZED), JSON_PRETTY_PRINT); } else { $ids = json_decode($_REQUEST['ids']); $stringIds = implode(",", $ids); $connection = \Yii::$app->db; if (Product::deleteAll('warehouse_id IN (' . $stringIds . ')')) { echo json_encode(array('status' => 1, 'code' => 200, 'data' => 'deleted'), JSON_PRETTY_PRINT); } else { echo json_encode(array('status' => 0, 'error_code' => Codes::$BAD_REQUEST), JSON_PRETTY_PRINT); } } }