Files
x-server-mobile/backend/app/Model/User.php
T

61 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace App\Model;
use support\Model;
class User extends Model
{
protected $table = 'user';
protected $fillable = [
'company_id',
'feishu_user_id',
'feishu_union_id',
'name',
'email',
'phone',
'avatar',
'status',
];
protected $casts = [
'company_id' => 'integer',
'status' => 'integer',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
/**
* 关联公司
*/
public function company()
{
return $this->belongsTo(Company::class, 'company_id');
}
/**
* 获取启用的用户
*/
public function scopeActive($query)
{
return $query->where('status', 1);
}
/**
* 根据飞书用户ID查找
*/
public function scopeByFeishuUserId($query, string $feishuUserId)
{
return $query->where('feishu_user_id', $feishuUserId);
}
/**
* 根据飞书 UnionID 查找
*/
public function scopeByFeishuUnionId($query, string $feishuUnionId)
{
return $query->where('feishu_union_id', $feishuUnionId);
}
}