diff --git a/app/adminapi/validate/land/LandValidate.php b/app/adminapi/validate/land/LandValidate.php index fe3e1e07..d6fbcd32 100644 --- a/app/adminapi/validate/land/LandValidate.php +++ b/app/adminapi/validate/land/LandValidate.php @@ -16,6 +16,7 @@ namespace app\adminapi\validate\land; use app\common\validate\BaseValidate; +use think\facade\Db; /** @@ -118,7 +119,7 @@ class LandValidate extends BaseValidate */ public function sceneDelete() { - return $this->only(['id']); + return $this->only(['id'])->append('id', 'require|checkLand');; } @@ -133,4 +134,13 @@ class LandValidate extends BaseValidate return $this->only(['id']); } + public function checkLand($value, $rule, $data) + { + $landProduct = Db::name('land_product')->where('land_id', $value)->findOrEmpty(); + if (!empty($landProduct)) { + return '存在关联产品,无法删除'; + } + return true; + } + } \ No newline at end of file