1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\admin\validate\goods;
-
-
- use app\common\basics\Validate;
- use app\common\model\goods\Goods;
-
-
- class UnitValidate extends Validate
- {
-
- protected $rule = [
- 'id' => 'require',
- 'name' => 'require|unique:goodsUnit,name&del'
- ];
-
- protected $message = [
- 'id.require' => '参数缺失',
- 'name.unique' => '该名称已被使用',
- ];
-
-
- protected $scene = [
- 'add' => ['name'],
- 'edit' => ['id','name'],
- ];
-
- public function sceneDel()
- {
- return $this->only(['id'])
- ->append('id','CheckUnit');
- }
-
- protected function CheckUnit($value, $rule, $data)
- {
- $check = Goods::where('unit_id', $value)->find();
- if ($check) {
- return '当前商品单位已使用,无法删除';
- }
- return true;
- }
-
- }
|