让分类、会员和示例工具共用同一账号,本地即可跑通登录与授权。 Co-authored-by: Cursor <cursoragent@cursor.com>
57 lines
1.2 KiB
PHP
57 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
|
|
class User extends Authenticatable
|
|
{
|
|
use HasFactory, Notifiable;
|
|
|
|
protected $fillable = [
|
|
'nickname',
|
|
'password',
|
|
'role',
|
|
'status',
|
|
'entitlement_version',
|
|
'disabled_reason',
|
|
];
|
|
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'password' => 'hashed',
|
|
'entitlement_version' => 'integer',
|
|
];
|
|
}
|
|
|
|
public function identities(): HasMany
|
|
{
|
|
return $this->hasMany(UserIdentity::class);
|
|
}
|
|
|
|
public function sessions(): HasMany
|
|
{
|
|
return $this->hasMany(UserSession::class);
|
|
}
|
|
|
|
public function subscription(): HasOne
|
|
{
|
|
return $this->hasOne(Subscription::class);
|
|
}
|
|
|
|
public function isStaff(): bool
|
|
{
|
|
return in_array($this->role, ['operator', 'super_admin'], true);
|
|
}
|
|
}
|