更新关联删除
This commit is contained in:
parent
8cdc2879c0
commit
45ee96a193
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue