Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
92 lines
2.1 KiB
PHP
92 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Laravel\Passkeys;
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Support\Carbon;
|
|
use Laravel\Passkeys\Contracts\PasskeyUser;
|
|
use Laravel\Passkeys\Support\Aaguids;
|
|
|
|
/**
|
|
* @mixin Builder<Passkey>
|
|
*
|
|
* @property int $id
|
|
* @property int|string $user_id
|
|
* @property string $name
|
|
* @property string $credential_id
|
|
* @property array<string, mixed> $credential
|
|
* @property Carbon|null $last_used_at
|
|
* @property Carbon|null $created_at
|
|
* @property Carbon|null $updated_at
|
|
* @property-read PasskeyUser $user
|
|
* @property-read string|null $authenticator
|
|
*/
|
|
class Passkey extends Model
|
|
{
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'credential_id',
|
|
'credential',
|
|
];
|
|
|
|
/**
|
|
* The accessors to append to the model's array form.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
protected $appends = [
|
|
'authenticator',
|
|
];
|
|
|
|
/**
|
|
* Get the attributes that should be cast.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'credential' => 'json',
|
|
'last_used_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get the user that owns the passkey.
|
|
*
|
|
* @return BelongsTo<Model, $this>
|
|
*/
|
|
public function user(): BelongsTo
|
|
{
|
|
/** @var class-string<Model> $model */
|
|
$model = Passkeys::userModel();
|
|
|
|
return $this->belongsTo($model, 'user_id');
|
|
}
|
|
|
|
/**
|
|
* Get the authenticator name based on the AAGUID.
|
|
*/
|
|
protected function authenticator(): Attribute
|
|
{
|
|
return Attribute::get(function (): ?string {
|
|
$aaguid = $this->credential['aaguid'] ?? null;
|
|
|
|
if (! is_string($aaguid) || $aaguid === Aaguids::unknown()) {
|
|
return null;
|
|
}
|
|
|
|
return Aaguids::labelFor($aaguid);
|
|
});
|
|
}
|
|
}
|