LockInfo.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace App\Model;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App\Events\LockEvent;
  5. class LockInfo extends Model
  6. {
  7. protected $table = 'device_lock_info';
  8. //锁类型 1 不重复 2每天 3每周
  9. const ONCE = 1;
  10. const EVERYDAY = 2;
  11. const EVERYWEEK = 3;
  12. public static $_lock_type = [
  13. self::ONCE=>'不重复',
  14. self::EVERYDAY=>'每天',
  15. self::EVERYWEEK=>'每周',
  16. ];
  17. public static function get_type()
  18. {
  19. return self::$_lock_type;
  20. }
  21. public static function week_day()
  22. {
  23. $array = [
  24. 1=>'星期一',
  25. 2=>'星期二',
  26. 3=>'星期三',
  27. 4=>'星期四',
  28. 5=>'星期五',
  29. 6=>'星期六',
  30. 7=>'星期天'
  31. ];
  32. return $array;
  33. }
  34. public static function month_day()
  35. {
  36. $array = [
  37. '1'=>'1号', '2'=>'2号', '3'=>'3号', '4'=>'4号', '5'=>'5号', '6'=>'6号', '7'=>'7号', '8'=>'8号', '9'=>'9号', '10'=>'10号',
  38. '11'=>'11号', '12'=>'12号', '13'=>'13号', '14'=>'14号', '15'=>'15号', '16'=>'16号', '17'=>'17号', '18'=>'18号', '19'=>'19号', '20'=>'20号',
  39. '21'=>'21号', '22'=>'22号', '23'=>'23号', '24'=>'24号', '25'=>'25号', '26'=>'26号', '27'=>'27号', '28'=>'28号', '29'=>'29号', '30'=>'30号',
  40. '31'=>'31号',
  41. ];
  42. return $array;
  43. }
  44. public function getValueAttribute($value)
  45. {
  46. return explode(',', $value);
  47. }
  48. public function setValueAttribute($value)
  49. {
  50. $this->attributes['value'] = implode(',', $value);
  51. }
  52. // protected $dispatchesEvents = [
  53. // 'updated'=>LockEvent::class
  54. // ];
  55. public function devices()
  56. {
  57. return $this->hasOne(DeviceInfo::class,'id','device_id');
  58. }
  59. }