1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace app\common\validate;
- use think\Db;
- use think\Validate;
- class FinanceLog extends Validate{
- protected $rule = [
- 'income|收入' => 'require|egt:0',
- 'expenditure|支出' => 'require|egt:0',
- 'day|日期' => 'require|date|checkUnique',
- ];
- protected $message = [
- ];
- protected $scene = [
- ];
- protected function checkUnique($value,$rule,$data=[])
- {
- $info = Db::name('finance_log')->where('day',$value)->where('org_id',$data['org_id'])->find();
- if($data['id'] <= 0 && $info){
- return '日期已被使用';
- }
- if($info && $data['id'] > 0 && $info['id'] != $data['id']){
- return '日期已被使用';
- }
- return true;
- }
- }
|