Advanced
Passkey Model
The Passkey Eloquent model provided by the Laravel Passkey API package.
The Passkey model represents a single registered WebAuthn credential in the database.
Namespace: Xefi\LaravelPasskey\Models\Passkey
Properties
| Property | Type | Description |
|---|---|---|
$id | int | Primary key |
$passkeeable_id | int | ID of the polymorphic owner |
$passkeeable_type | string | Class of the polymorphic owner (e.g. App\Models\User) |
$label | string | Human-readable name for this passkey |
$credential_id | string | Base64-encoded WebAuthn credential ID |
$challenge | string | Base64url-encoded challenge used during the last registration |
$public_key | string | Base64-encoded CBOR-encoded COSE public key |
$created_at | Carbon | |
$updated_at | Carbon |
Relationships
passkeeable()
Returns the model that owns this passkey (polymorphic).
public function passkeeable(): MorphTo
$passkey = Passkey::find(1);
$user = $passkey->passkeeable; // App\Models\User instance (or any other model)
Direct usage
You can query the Passkey model directly in your own code:
use Xefi\LaravelPasskey\Models\Passkey;
// Find a passkey by credential ID
$passkey = Passkey::where('credential_id', $credentialId)->firstOrFail();
// Get the owner behind a passkey
$user = $passkey->passkeeable;
// Delete a specific passkey belonging to the authenticated user
Passkey::where('id', $passkeyId)
->where('passkeeable_id', auth()->id())
->where('passkeeable_type', \App\Models\User::class)
->delete();
Fillable fields
The following fields are mass-assignable:
protected $fillable = [
'label',
'passkeeable_id',
'passkeeable_type',
'credential_id',
'challenge',
'public_key',
];