PHPackages                             dtconline/filament-edit-profile - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Admin Panels](/categories/admin)
4. /
5. dtconline/filament-edit-profile

ActiveLibrary[Admin Panels](/categories/admin)

dtconline/filament-edit-profile
===============================

Filament package to edit profile

v1.0.32(1y ago)012MITPHPPHP ^8.1

Since Sep 25Pushed 1y agoCompare

[ Source](https://github.com/TLSGROUP/filament-edit-profile)[ Packagist](https://packagist.org/packages/dtconline/filament-edit-profile)[ Docs](https://github.com/TLSGROUP/filament-edit-profile)[ GitHub Sponsors](https://github.com/TLSGROUP)[ RSS](/packages/dtconline-filament-edit-profile/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (10)Versions (3)Used By (0)

Filament package to edit profile
================================

[](#filament-package-to-edit-profile)

[![Latest Version on Packagist](https://camo.githubusercontent.com/44eab2ae1b3fc411b4d83c425a340c152d9d291fe13b57b10b7b3faf442e729d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f544c5347524f55502f66696c616d656e742d656469742d70726f66696c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/TLSGROUP/filament-edit-profile)[![GitHub Tests Action Status](https://camo.githubusercontent.com/3fbdc68e1e199802c08047d9b9855dbd9752aae9ae0042677e660d810698cb7b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f544c5347524f55502f66696c616d656e742d656469742d70726f66696c652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/TLSGROUP/filament-edit-profile/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/e69b5210e174f0e9035da16f70aab16c35a54aa833de20d233f21eaf6b54cd2a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f544c5347524f55502f66696c616d656e742d656469742d70726f66696c652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/TLSGROUP/filament-edit-profile/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/0f0b772f90684788d76bd5a09ff4d58296f5803854472d5f2ac3493abd0acaf8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f544c5347524f55502f66696c616d656e742d656469742d70726f66696c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/TLSGROUP/filament-edit-profile)

The Filament library is a user-friendly tool that simplifies profile editing, offering an intuitive interface and robust features to easily customize and manage user information.

[![Screenshot of Application Feature](https://raw.githubusercontent.com/TLSGROUP/filament-edit-profile/main/art/TLSGROUP-filament-edit-profile.jpg)](https://raw.githubusercontent.com/TLSGROUP/filament-edit-profile/main/art/TLSGROUP-filament-edit-profile.jpg)

Features &amp; Screenshots
--------------------------

[](#features--screenshots)

- **Edit Information:** Manage your information such as email, and password.
- **Change Password:** Change your password.
- **Profile Photo:** Upload and manage your profile photo.
- **Delete Account:** Manage your account, such as delete account.
- **Sanctum Personal Access tokens:** Manage your personal access tokens.
- **Browser Sessions** Manage and log out your active sessions on other browsers and devices.
- **Custom Fields:** Add custom fields to the form.
- **Custom Components:** Add custom component to the page.
- **Support**: [Laravel 11](https://laravel.com) and [Filament 3.x](https://filamentphp.com)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require dtconline/filament-edit-profile
```

You can publish and run the migrations with:

Optionally, you can publish the views using

```
php artisan vendor:publish --tag="filament-edit-profile-views"
```

Optionally, you can publish the translations using

```
php artisan vendor:publish --tag="filament-edit-profile-translations"
```

You can publish and run all the migrations with:

```
php artisan vendor:publish --tag="filament-edit-profile-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="filament-edit-profile-config"
```

Usage
-----

[](#usage)

Add in AdminPanelProvider.php

```
use DtcOnline\FilamentEditProfile\FilamentEditProfilePlugin;

->plugins([
    FilamentEditProfilePlugin::make()
])
```

if you want to show for specific parameters to sort, icon, title, navigation group, navigation label and can access, you can use the following example:

```
use DtcOnline\FilamentEditProfile\FilamentEditProfilePlugin;

 ->plugins([
     FilamentEditProfilePlugin::make()
        ->slug('my-profile')
        ->setTitle('My Profile')
        ->setNavigationLabel('My Profile')
        ->setNavigationGroup('Group Profile')
        ->setIcon('heroicon-o-user')
        ->setSort(10)
        ->canAccess(fn () => auth()->user()->id === 1)
        ->shouldRegisterNavigation(false)
        ->shouldShowDeleteAccountForm(false)
        ->shouldShowSanctumTokens()
        ->shouldShowBrowserSessionsForm()
        ->shouldShowAvatarForm()
        ->customProfileComponents([
            \App\Livewire\CustomProfileComponent::class,
        ])
 ])
```

Optionally, you can add a user menu item to the user menu in the navigation bar:

```
use Filament\Navigation\MenuItem;
use DtcOnline\FilamentEditProfile\Pages\EditProfilePage;

->userMenuItems([
    'profile' => MenuItem::make()
        ->label(fn() => auth()->user()->name)
        ->url(fn (): string => EditProfilePage::getUrl())
        ->icon('heroicon-m-user-circle')
        //If you are using tenancy need to check with the visible method where ->company() is the relation between the user and tenancy model as you called
        ->visible(function (): bool {
            return auth()->user()->company()->exists();
        }),
])
```

Profile Avatar
--------------

[](#profile-avatar)

[![Screenshot of avatar Feature](https://raw.githubusercontent.com/TLSGROUP/filament-edit-profile/main/art/profile-avatar.png)](https://raw.githubusercontent.com/TLSGROUP/filament-edit-profile/main/art/profile-avatar.png)Show the user avatar form using `shouldShowAvatarForm()`. This package follows the [Filament user avatar](https://filamentphp.com/docs/3.x/panels/users#setting-up-user-avatars) to manage the avatar.

To show the avatar form, you need the following steps:

1. Publish the migration file to add the avatar\_url field to the users table:

```
php artisan vendor:publish --tag="filament-edit-profile-avatar-migration"
php artisan migrate
```

2. Add in your User model the avatar\_url field in the fillable array:

```
protected $fillable = [
    'name',
    'email',
    'password',
    'avatar_url',
];
```

3. Set the getFilamentAvatarUrlAttribute method in your User model:

```
use Filament\Models\Contracts\HasAvatar;
use Illuminate\Support\Facades\Storage;

class User extends Authenticatable implements HasAvatar
{
    // ...
    public function getFilamentAvatarUrl(): ?string
    {
        return $this->avatar_url ? Storage::url("$this->avatar_url") : null;
    }
}
```

4. Optionally, you can specify the image directory path and file upload rules. :

```
->shouldShowAvatarForm(
    value: true,
    directory: 'avatars', // image will be stored in 'storage/app/public/avatars
    rules: 'mimes:jpeg,png|max:1024' //only accept jpeg and png files with a maximum size of 1MB
)
```

5. Don't forget to run the command `php artisan storage:link`

Sanctum Personal Access tokens
------------------------------

[](#sanctum-personal-access-tokens)

Show the Sanctum token management component:

Please review [Laravel Sanctum Docs](https://laravel.com/docs/11.x/sanctum)

You may install Laravel Sanctum via the `install:api` Artisan command:

```
php artisan install:api
```

Sanctum allows you to issue API tokens / personal access tokens that may be used to authenticate API requests to your application. When making requests using API tokens, the token should be included in the Authorization header as a Bearer token.

```
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable;
}
```

[![Screenshot of Application Feature](https://raw.githubusercontent.com/TLSGROUP/filament-edit-profile/main/art/sanctum_tokens.png)](https://raw.githubusercontent.com/TLSGROUP/filament-edit-profile/main/art/sanctum_tokens.png)

If you want to control access, you can use `condition`, passing Closure or Boolean

Sanctum allows you to assign "abilities" to tokens. by default we have \['create', 'view', 'update', 'delete'\] use `permissions` to customize

```
 ->plugins([
    FilamentEditProfilePlugin::make()
        ->shouldShowSanctumTokens(
            condition: fn() => auth()->user()->id === 1, //optional
            permissions: ['custom', 'abilities', 'permissions'] //optional
        )
 ])
```

Browser Sessions
----------------

[](#browser-sessions)

[![Screenshot of Application Feature](https://raw.githubusercontent.com/TLSGROUP/filament-edit-profile/main/art/browser-sessions.png)](https://raw.githubusercontent.com/TLSGROUP/filament-edit-profile/main/art/browser-sessions.png)

To utilize browser session, ensure that your session configuration's driver (or SESSION\_DRIVER environment variable) is set to `database`.

```
SESSION_DRIVER=database
```

If you want to control access or disable browser sessions, you can pass a Closure or Boolean

```
 ->plugins([
    FilamentEditProfilePlugin::make()
        ->shouldShowBrowserSessionsForm(
            fn() => auth()->user()->id === 1, //optional
                //OR
            false //optional
        )
 ])
```

Custom Fields
-------------

[](#custom-fields)

[![Screenshot of Application Feature](https://raw.githubusercontent.com/TLSGROUP/filament-edit-profile/main/art/custom_fields.png)](https://raw.githubusercontent.com/TLSGROUP/filament-edit-profile/main/art/custom_fields.png)Optionally, you can add custom fields to the form. To create custom fields you need to follow the steps below:

1. Publish the migration file to add the custom fields to the users table:

```
php artisan vendor:publish --tag="filament-edit-profile-custom-field-migration"
php artisan migrate
```

2. Add in your User model the custom field in the fillable array:

```
protected $fillable = [
    'name',
    'email',
    'password',
    'custom_fields',
];
```

3. Add in your User model the custom field in the casts array:

```
protected function casts(): array
{
    return [
        'email_verified_at' => 'datetime',
        'password' => 'hashed',
        'custom_fields' => 'array'
    ];
}
```

5. Publish the config file using this command:

```
php artisan vendor:publish --tag="filament-edit-profile-config"
```

6. Edit the config file `config/filament-edit-profile.php` to add the custom fields to the form as example below:

```
