代码优化
This commit is contained in:
25
Server/application/cunkebao/model/User.php
Normal file
25
Server/application/cunkebao/model/User.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 用户模型
|
||||
*/
|
||||
class User extends Model
|
||||
{
|
||||
protected $pk = 'id';
|
||||
protected $name = 'users';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'createTime';
|
||||
protected $updateTime = 'updateTime';
|
||||
|
||||
// 定义关联的工作台
|
||||
public function workbench()
|
||||
{
|
||||
return $this->hasMany('Workbench', 'id', 'userId');
|
||||
}
|
||||
}
|
||||
@@ -55,4 +55,9 @@ class Workbench extends Model
|
||||
return $this->hasOne('WorkbenchGroupCreate', 'workbenchId', 'id');
|
||||
}
|
||||
|
||||
// 用户关联
|
||||
public function user()
|
||||
{
|
||||
return $this->hasOne('User', 'id', 'userId');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user