mortezamasumi / fb-profile
Add a configurable profile form to your Filament user menu.
Requires
- php: ^8.3
- ariaieboy/filament-jalali: ^3.0
- filament/filament: ^5.0
- mortezamasumi/fb-essentials: ^5.0
- spatie/laravel-package-tools: ^1.0
Requires (Dev)
- filament/upgrade: ^5.0
- larastan/larastan: ^3.10
- laravel/pint: ^1.30
- league/uri-components: ^7.5
- orchestra/testbench: ^10.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-browser: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- pestphp/pest-plugin-livewire: ^4.0
- phpstan/phpstan: ^2.2
README
A Filament panel plugin that adds a configurable profile form to the user menu, with Persian-aware inputs (avatar upload, name, NID, gender, birth date, mobile, email, username) and an Iranian national ID validator.
Features
- Profile page — replaces the default Filament profile page with a richer, configurable form
- Avatar upload — square avatar with configurable disk, folder, visibility and size limit
- Iranian NID validation — checksum-validated, with a passport-number bypass option
- Persian input helpers — Persian-to-English digit conversion on NID, mobile and email
- Required-field toggles — make mobile, email, username, NID, gender or birth date required via config
- Custom components hook — extend the form from your user model
- Localized — ships English and Persian translations
Installation
composer require mortezamasumi/fb-profile
Add the plugin to your Filament panel provider:
use Mortezamasumi\FbProfile\FbProfilePlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ FbProfilePlugin::make(), ]); }
Configuration
Publish the config file:
php artisan vendor:publish --tag="fb-profile-config"
| Key | Default | Description |
|---|---|---|
max_avatar_size |
200 |
Max avatar upload size in KB |
avatar_disk |
public |
Disk for avatar uploads |
avatar_visibility |
public |
Avatar visibility |
avatar_folder |
/uploads/avatars |
Avatar upload folder |
mobile_required |
false |
Require the mobile field |
email_required |
false |
Require the email field |
username_required |
false |
Require the username field |
nid_required |
false |
Require the national ID field |
use_passport_number_on_nid |
false |
Accept passport numbers instead of NIDs |
gender_required |
false |
Require the gender field |
birth_date_required |
false |
Require the birth date field |
profile_form_columns |
3 |
Columns in the profile form grid |
Usage
Once the plugin is registered, the profile page is available from the user menu. The form reads your user model's columns; the fields are fully optional unless you enable the *_required flags above.
Extending the form
Your user model can add extra fields or replace the whole form:
// In your User model — prepend the default fields, then append yours public static function extraProfileComponents(): array { return [ \Filament\Forms\Components\TextInput::make('bio')->label('Bio'), ]; } // Or define a full custom form public static function customProfileForm(): array { return [ \Filament\Forms\Components\TextInput::make('first_name'), ]; }
Iranian NID validation
The iran_nid validation rule validates the Iranian national ID checksum. It is active in production only, and is bypassed when use_passport_number_on_nid is enabled.
$this->validate(['nid' => ['required', 'iran_nid']]);
Support policy
| PHP | Laravel |
|---|---|
| 8.3 | 12 |
Testing
composer test
The test suite covers the user menu entry, profile updates, redirect behaviour, and the Iranian NID validator using an in-memory SQLite database.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover a security vulnerability, please review our security policy on how to report it.
Changelog
Please see CHANGELOG for recent changes.
License
The MIT License (MIT). See LICENSE.md for details.