Using a custom passkey model | laravel-passkeys | Spatie

 SPATIE

  Laravel Passkeys
===================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-passkeys](https://spatie.be/docs/laravel-passkeys/v1)  Advanced-usage  Using a custom passkey model

 Version   v1

 Other versions for crawler [v1](https://spatie.be/docs/laravel-passkeys/v1)

- [ Introduction ](https://spatie.be/docs/laravel-passkeys/v1/introduction)
- [ Support us ](https://spatie.be/docs/laravel-passkeys/v1/support-us)
- [ Requirements ](https://spatie.be/docs/laravel-passkeys/v1/requirements)
- [ Installation &amp; setup ](https://spatie.be/docs/laravel-passkeys/v1/installation-setup)
- [ Questions and issues ](https://spatie.be/docs/laravel-passkeys/v1/questions-issues)
- [ Changelog ](https://spatie.be/docs/laravel-passkeys/v1/changelog)
- [ About us ](https://spatie.be/docs/laravel-passkeys/v1/about-us)

Basic usage
-----------

- [ How passkeys work ](https://spatie.be/docs/laravel-passkeys/v1/basic-usage/how-passkeys-work)
- [ Generating passkeys ](https://spatie.be/docs/laravel-passkeys/v1/basic-usage/generating-passkeys)
- [ Authentication using passkeys ](https://spatie.be/docs/laravel-passkeys/v1/basic-usage/authenticating-using-passkeys)
- [ Styling the components ](https://spatie.be/docs/laravel-passkeys/v1/basic-usage/styling-the-components)
- [ Usage in Inertia ](https://spatie.be/docs/laravel-passkeys/v1/basic-usage/usage-in-inertia)

Advanced usage
--------------

- [ Using a custom passkey model ](https://spatie.be/docs/laravel-passkeys/v1/advanced-usage/using-a-custom-passkey-model)
- [ Customizing behaviour ](https://spatie.be/docs/laravel-passkeys/v1/advanced-usage/customizing-behaviour)
- [ Listening for events ](https://spatie.be/docs/laravel-passkeys/v1/advanced-usage/listening-for-events)

 Using a custom passkey model
============================

###  On this page

1. [ Step 1: Create a custom model ](#content-step-1-create-a-custom-model)
2. [ Step 2: Update the configuration ](#content-step-2-update-the-configuration)

By default, the package uses the `Spatie\Passkeys\Models\Passkey` model to store passkeys. If you want to use a custom model, you can do so by following these steps.

Step 1: Create a custom model
---------------------------------------------------------------------------------------------------------------------------------------------

Create a new model that extends the `Spatie\Passkeys\Models\Passkey` model.

```
namespace App\Models;

use Spatie\Passkeys\Models\Passkey as BasePasskey;

class Passkey extends BasePasskey
{
    // Add any custom properties or methods here
}
```

Step 2: Update the configuration
------------------------------------------------------------------------------------------------------------------------------------------------------

Next, you need to update the `config/passkeys.php` configuration file to use your custom model.

```
// config/passkeys.php

return [
    // ...
    'models' => [
        // The model used to store passkeys
        'passkey_model' => App\Models\Passkey::class,
    ],
];
```
