12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace app\common\validate;
- use think\Validate;
- use think\Db;
- class HouseTurnLessee extends Validate{
- protected $rule =[
- 'house_turn_id' => 'require|checkTurn',
- 'lessee_id' => 'require|gt:0',
- 'start_time' => 'require|date',
- ];
- protected $message = [
- 'house_turn_id.require' => '参数错误',
- 'lessee_id.require' => '未选择入住人',
- 'lessee_id.gt' => '未选择入住人',
- 'start_time.require' => '未选择入住日期',
- 'start_time.gt' => '未选择入住日期',
- ];
- protected $scene = [
- ];
- protected function checkTurn($value,$rule,$data=[])
- {
- $info = Db::name('house_turn')->where('id',$data['house_turn_id'])->find();
- if(!$info||$info['del'] == 1){
- return '参数错误';
- }
- if($info['enable'] == 0){
- return '房间被禁用';
- }
- if($info['cur_lessee_id'] > 0){
- return '该房间有入住人';
- }
- return true;
- }
- }
|