123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace App\Model;
- use Illuminate\Database\Eloquent\Model;
- use App\Events\LockEvent;
- class LockInfo extends Model
- {
- protected $table = 'device_lock_info';
- //锁类型 1 不重复 2每天 3每周
- const ONCE = 1;
- const EVERYDAY = 2;
- const EVERYWEEK = 3;
- public static $_lock_type = [
- self::ONCE=>'不重复',
- self::EVERYDAY=>'每天',
- self::EVERYWEEK=>'每周',
- ];
- public static function get_type()
- {
- return self::$_lock_type;
- }
- public static function week_day()
- {
- $array = [
- 1=>'星期一',
- 2=>'星期二',
- 3=>'星期三',
- 4=>'星期四',
- 5=>'星期五',
- 6=>'星期六',
- 7=>'星期天'
- ];
- return $array;
- }
- public static function month_day()
- {
- $array = [
- '1'=>'1号', '2'=>'2号', '3'=>'3号', '4'=>'4号', '5'=>'5号', '6'=>'6号', '7'=>'7号', '8'=>'8号', '9'=>'9号', '10'=>'10号',
- '11'=>'11号', '12'=>'12号', '13'=>'13号', '14'=>'14号', '15'=>'15号', '16'=>'16号', '17'=>'17号', '18'=>'18号', '19'=>'19号', '20'=>'20号',
- '21'=>'21号', '22'=>'22号', '23'=>'23号', '24'=>'24号', '25'=>'25号', '26'=>'26号', '27'=>'27号', '28'=>'28号', '29'=>'29号', '30'=>'30号',
- '31'=>'31号',
- ];
- return $array;
- }
- public function getValueAttribute($value)
- {
- return explode(',', $value);
- }
- public function setValueAttribute($value)
- {
- $this->attributes['value'] = implode(',', $value);
- }
- // protected $dispatchesEvents = [
- // 'updated'=>LockEvent::class
- // ];
- public function devices()
- {
- return $this->hasOne(DeviceInfo::class,'id','device_id');
- }
- }
|