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.

56 lines
1.1 KiB

1 month ago
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Sanctum\HasApiTokens;
class CompetitionAdmin extends Authenticatable
{
use HasApiTokens;
protected $fillable = [
'competition_id',
'username',
'password_hash',
'name',
4 weeks ago
'mobile',
'event_location',
1 month ago
'status',
'last_login_at',
];
protected $hidden = [
'password_hash',
];
/**
* @var array<string, string>
*/
protected $casts = [
'last_login_at' => 'datetime',
'password_hash' => 'hashed',
];
public function competition(): BelongsTo
{
return $this->belongsTo(Competition::class);
}
public function getAuthPassword(): ?string
{
return $this->password_hash;
}
public function usesPassword(): bool
{
return $this->password_hash !== null && $this->password_hash !== '';
}
public function belongsToCompetition(int $competitionId): bool
{
return (int) $this->competition_id === $competitionId;
}
}