HouseTurnLessee.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace app\common\validate;
  3. use think\Validate;
  4. use think\Db;
  5. class HouseTurnLessee extends Validate{
  6. protected $rule =[
  7. 'house_turn_id' => 'require|checkTurn',
  8. 'lessee_id' => 'require|gt:0',
  9. 'start_time' => 'require|date',
  10. ];
  11. protected $message = [
  12. 'house_turn_id.require' => '参数错误',
  13. 'lessee_id.require' => '未选择入住人',
  14. 'lessee_id.gt' => '未选择入住人',
  15. 'start_time.require' => '未选择入住日期',
  16. 'start_time.gt' => '未选择入住日期',
  17. ];
  18. protected $scene = [
  19. ];
  20. protected function checkTurn($value,$rule,$data=[])
  21. {
  22. $info = Db::name('house_turn')->where('id',$data['house_turn_id'])->find();
  23. if(!$info||$info['del'] == 1){
  24. return '参数错误';
  25. }
  26. if($info['enable'] == 0){
  27. return '房间被禁用';
  28. }
  29. if($info['cur_lessee_id'] > 0){
  30. return '该房间有入住人';
  31. }
  32. return true;
  33. }
  34. }