profile-filament-plugin

Pages

Profile

The Profile page is typically the starting page for the user profile in this plugin. By default, it will display a user's name and the date their account was created, along with a form to edit their name. This, of course, can be customized according to your application's requirements.

Here is a screenshot of what the base Profile page will look like:

base profile page

And here is the default edit form:

base profile edit form

For basic applications, the plugin's implementation may be enough. However, most applications will probably have a need to override the ProfileInfo component.

Let's say you need to show a user's timezone and allow them to edit it as well on their profile info. This can be done by configuring the infolist and edit action in a service provider. If you need full control over the component or prefer not to customize it this way, you may swap the component instead.

To accomplish this, the two main methods we need to override are the infolistSchema and formSchema methods. There are other methods that can be overridden, such as saveForm, but what we are going to show below should be sufficient in most cases.

use App\Models\User;
use Filament\Forms\Components\Select;
use Filament\Schemas\Components\Section;
use Rawilk\ProfileFilament\Filament\Actions\EditProfileInfoAction;
use Rawilk\ProfileFilament\Filament\Schemas\Forms\Inputs\ProfileNameInput;
use Rawilk\ProfileFilament\Filament\Schemas\Infolists\ProfileInfolist;

class AppServiceProvider
{
    public function boot()
    {
        EditProfileInfoAction::configureUsing(function (EditProfileInfoAction $action) {
            $action
                ->schema([
                    ProfileNameInput::make(),
                    Select::make('timezone')
                        ->options([
                            // ...
                        ])
                ])
        });

        ProfileInfolist::configureComponents(function (User $user) {
            return [
                Section::make(__('Profile Information'))
                    ->headerActions([
                        EditProfileInfoAction::make()
                    ])
                    ->schema([
                        ProfileInfolist::nameComponent(),
                        TextEntry::make('timezone'),
                    ])
            ];
        });
    }
}

If you want to swap the component instead, here is how to do it in your panel's service provider:

use Rawilk\ProfileFilament\Filament\Pages\ProfileTemp\ProfileInfo as ProfileInfoPage;
use Rawilk\ProfileFilament\ProfileFilamentPlugin;
use Rawilk\ProfileFilament\Livewire\Profile\ProfileInfo;

$panel->plugin(
    ProfileFilamentPlugin::make()
        ->swapComponent(
            page: ProfileInfoPage::class,
            component: ProfileInfo::class,
            newComponent: YourCustomProfileInfo::class,
        )
)

{tip} It's not necessary to extend the plugin's livewire component in this case; you are free to use a completely custom class if you want.

By default, our EditProfileInfoAction will dispatch the \Rawilk\ProfileFilament\Events\Profile\ProfileInformationUpdated event, which you can listen for in your application if needed. The event will receive the authenticated user.

Previous
Changelog