2025-03-27 18:08:28 +08:00
|
|
|
<?php
|
2025-04-16 17:14:48 +08:00
|
|
|
|
2025-03-27 18:08:28 +08:00
|
|
|
namespace app\common\model;
|
|
|
|
|
|
|
|
|
|
use think\Model;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设备用户关联模型
|
|
|
|
|
* 用于管理设备与操盘手(用户)的关联关系
|
|
|
|
|
*/
|
|
|
|
|
class DeviceUser extends Model
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* 数据表名
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2025-04-16 16:10:37 +08:00
|
|
|
protected $name = 'device_user';
|
|
|
|
|
|
2025-04-16 17:14:48 +08:00
|
|
|
// 自动写入时间戳
|
|
|
|
|
protected $autoWriteTimestamp = true;
|
|
|
|
|
protected $createTime = 'createTime';
|
|
|
|
|
protected $updateTime = 'updateTime';
|
|
|
|
|
|
2025-03-27 18:08:28 +08:00
|
|
|
/**
|
|
|
|
|
* 关联用户模型
|
|
|
|
|
* @return \think\model\relation\BelongsTo
|
|
|
|
|
*/
|
|
|
|
|
public function user()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo('User', 'userId', 'id');
|
|
|
|
|
}
|
2025-04-16 17:14:48 +08:00
|
|
|
|
2025-03-27 18:08:28 +08:00
|
|
|
/**
|
|
|
|
|
* 关联设备模型
|
|
|
|
|
* @return \think\model\relation\BelongsTo
|
|
|
|
|
*/
|
|
|
|
|
public function device()
|
|
|
|
|
{
|
2025-04-16 17:14:48 +08:00
|
|
|
return $this->belongsTo('app\common\model\Device', 'deviceId', 'id');
|
2025-03-27 18:08:28 +08:00
|
|
|
}
|
2025-04-16 17:14:48 +08:00
|
|
|
|
2025-03-27 18:08:28 +08:00
|
|
|
/**
|
|
|
|
|
* 关联公司模型
|
|
|
|
|
* @return \think\model\relation\BelongsTo
|
|
|
|
|
*/
|
|
|
|
|
public function company()
|
|
|
|
|
{
|
2025-04-16 17:14:48 +08:00
|
|
|
return $this->belongsTo('app\common\model\Company', 'companyId', 'id');
|
2025-03-27 18:08:28 +08:00
|
|
|
}
|
|
|
|
|
}
|