You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.0 KiB

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Sanctum\HasApiTokens;
class AdminUser extends Authenticatable
{
use HasApiTokens, HasFactory;
protected $table = 'admin_users';
protected $fillable = [
'mobile',
'username',
'password_hash',
'name',
'status',
'last_login_at',
];
protected $hidden = [
'password_hash',
];
/**
* @var array<string, string>
*/
protected $casts = [
'last_login_at' => 'datetime',
'password_hash' => 'hashed',
];
public function getAuthPassword(): ?string
{
return $this->password_hash;
}
public function usesPassword(): bool
{
return $this->password_hash !== null && $this->password_hash !== '';
}
/** 仅 username=superadmin 可代登选手端 */
public function isSuperAdmin(): bool
{
return (string) $this->username === 'superadmin';
}
}