Skip to content

Commit

Permalink
Add migrations and update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Baspa committed Aug 16, 2024
1 parent 8030496 commit 670b4ca
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ class User extends Authenticatable implements FilamentUser
}
```

Also define the `two_factor_type` cast on your user model:

```php
use Vormkracht10\TwoFactorAuth\Enums\TwoFactorType;

// ...

protected function casts(): array
{
return [
'two_factor_type' => TwoFactorType::class,
];
}
```

> ❗ When using `fillable` instead of `guarded` on your model, make sure to add `two_factor_type` to the `$fillable` array.
In case you're not using Laravel 11 yet, you will probably need to manually register the event listener in your `EventServiceProvider`:

```php
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Vormkracht10\TwoFactorAuth\Enums\TwoFactorType;

return new class extends Migration
{
public function up()
{
if (!Schema::hasColumn('users', 'two_factor_type') && Schema::hasColumn('users', 'two_factor_recovery_codes')) {
Schema::table('users', function (Blueprint $table) {
$table->enum('two_factor_type', TwoFactorType::names())->nullable()->after('two_factor_recovery_codes');
});
}
}
};
19 changes: 0 additions & 19 deletions database/migrations/create_two_factor_auth_table.php.stub

This file was deleted.

2 changes: 1 addition & 1 deletion src/TwoFactorAuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ protected function getScriptData(): array
protected function getMigrations(): array
{
return [
'create_filament-two-factor-auth_table',
'add_two_factor_type_column_to_users_table',
];
}
}

0 comments on commit 670b4ca

Please sign in to comment.