You've already forked think-plugs-staff
feat(model): 为 StaffUser模型添加 profile 关联
- 在 StaffUser 模型中添加 profile 方法,建立与 XzglProfile 模型的关联 - 使用 hasOne 关系,通过 id 字段进行关联
This commit is contained in:
@@ -6,6 +6,7 @@ use think\admin\Model;
|
|||||||
use think\admin\model\SystemUser;
|
use think\admin\model\SystemUser;
|
||||||
use think\db\Query;
|
use think\db\Query;
|
||||||
use think\model\relation\HasOne;
|
use think\model\relation\HasOne;
|
||||||
|
use app\xzgl\model\XzglProfile;
|
||||||
|
|
||||||
class StaffUser extends Model
|
class StaffUser extends Model
|
||||||
{
|
{
|
||||||
@@ -41,4 +42,9 @@ class StaffUser extends Model
|
|||||||
{
|
{
|
||||||
return $this->dept ? $this->dept['name'] : '';
|
return $this->dept ? $this->dept['name'] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function profile(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(XzglProfile::class, 'id', 'id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user