Xboard/app/Models/User.php

51 lines
1.1 KiB
PHP
Raw Normal View History

2023-11-17 01:44:01 -05:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
2025-01-06 12:20:11 -05:00
use Illuminate\Foundation\Auth\User as Authenticatable;
2023-12-08 02:43:17 -05:00
use Laravel\Sanctum\HasApiTokens;
2023-11-17 01:44:01 -05:00
2025-01-06 12:20:11 -05:00
class User extends Authenticatable
2023-11-17 01:44:01 -05:00
{
2025-01-06 12:20:11 -05:00
use HasApiTokens;
2023-11-17 01:44:01 -05:00
protected $table = 'v2_user';
protected $dateFormat = 'U';
protected $guarded = ['id'];
protected $casts = [
'created_at' => 'timestamp',
'updated_at' => 'timestamp'
];
2025-01-06 12:20:11 -05:00
protected $hidden = ['password'];
// 获取邀请人信息
public function invite_user()
{
return $this->belongsTo(self::class, 'invite_user_id', 'id');
}
2023-12-08 02:43:17 -05:00
// 获取用户套餐
public function plan()
{
return $this->belongsTo(Plan::class, 'plan_id', 'id');
}
2025-01-06 12:20:11 -05:00
public function group()
{
return $this->belongsTo(ServerGroup::class, 'group_id', 'id');
}
// 获取用户邀请码列表
public function codes()
{
return $this->hasMany(InviteCode::class, 'user_id', 'id');
}
// 关联工单列表
public function tickets()
{
return $this->hasMany(Ticket::class, 'user_id', 'id');
}
2023-11-17 01:44:01 -05:00
}