🔒 Passwords made easy in Filament PHP 🤫
This package allows you to add a feature rich password field for Filament PHP.
https://packagist.org/packages/discoverydesign/filament-locksmith
- Ability to copy password
- Ability to automatically generate passwords. Default to 32 random character string.
- User-friendly preset generator, creates 3 word combo passwords. E.g:
elephant-plant-photo
. - Automatically hash password when storing to database. Useful when a cast can't be used.
- Block password field being editable, forcing a randomly generated password.
- Install the package using
composer require discoverydesign/filament-locksmith
- Import the package inside your Filament Form with
use DiscoveryDesign\FilamentLocksmith\Forms\Components\PasswordInput
. - Add the
PasswordInput
form component to your form withPasswordInput::make()
. - If required, publish the translation files with
php artisan vendor:publish --tag=filament-locksmith-translations
.
<?php
namespace App\Filament\Resources;
use DiscoveryDesign\FilamentLocksmith\Forms\Components\PasswordInput;
// ...
class UserResource extends Resource
{
// ...
public static function form(Form $form): Form
{
return $form
->schema([
PasswordInput::make('password')
->required()
->generatable()
->editable(false)
->friendly()
->copyable()
->revealable(),
// ...
]);
}
// ...
}
generatable
can be used to set if this password field should allow for an automatic password to be generated. This by default will generate a 32 character random string.
state
- (optional, bool) If the password should be generatable.
friendly
is a preloaded generator that creates a user friendly password. This password consists of 3 words that are combinred with '-'. E.g time-shelf-bottle
copyable
can be used to set if this password field should copyable to clipboard.
state
- (optional, bool) If the password should be copyable.
editable
can be used to block the password field being edited. This is normally combined with ->generatable()
.
state
- (optional, bool) If the password should be editable.
generator
allows you to define a custom generator that is used to create a password.
func
- (optional, closure | bool) The function used to generate the password. This function must return a string.
hashed
can be used if the password should be hashed before being stored. In most cases, you should instead use a cast against your model.
state
- (optional, bool) If the password should be hashed.
revealable
can be used to allow the password to be revealed. This is just Filament's built in reveal functionality.
func
- (optional, closure | bool) If the password should be revealable. If a closure is passed, this should return a bool.
🚀 Discovery Design