diff --git a/plugin/admin/app/controller/VehicleController.php b/plugin/admin/app/controller/VehicleController.php index 7d74274..6eff254 100644 --- a/plugin/admin/app/controller/VehicleController.php +++ b/plugin/admin/app/controller/VehicleController.php @@ -13,6 +13,7 @@ use app\service\OssService; use plugin\admin\app\common\Util; use plugin\admin\app\model\Location; use support\Cache; +use support\Db; use support\Log; use support\Request; use support\Response; @@ -625,4 +626,21 @@ class VehicleController extends Crud return json(['code' => 0, 'msg' => 'success', 'data' => $translations]); } + + public function delete(Request $request): Response + { + $id = $request->input('id'); + Db::beginTransaction(); + try { + $return = Vehicle::where('id', $id)->delete(); + VehicleEn::where('id', $id)->delete(); + VehicleRu::where('id', $id)->delete(); + VehicleAr::where('id', $id)->delete(); + Db::commit(); + return $this->json(0); + } catch (\Throwable $th) { + Db::rollBack(); + return $this->json(-1, $th->getMessage()); + } + } }