更新关联删除

This commit is contained in:
yaooo 2023-11-28 13:51:06 +08:00
parent 8cdc2879c0
commit 45ee96a193
1 changed files with 11 additions and 1 deletions

View File

@ -16,6 +16,7 @@ namespace app\adminapi\validate\land;
use app\common\validate\BaseValidate; use app\common\validate\BaseValidate;
use think\facade\Db;
/** /**
@ -118,7 +119,7 @@ class LandValidate extends BaseValidate
*/ */
public function sceneDelete() 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']); 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;
}
} }