Skip to content
Open
8 changes: 4 additions & 4 deletions app-modules/identity/src/User/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Concerns\HasAddress;
use Carbon\CarbonInterface;
use Filament\Models\Contracts\FilamentUser;
use Filament\Models\Contracts\HasAvatar;
use Filament\Models\Contracts\HasName;
use Filament\Panel;
use He4rt\Activity\Tracking\Concerns\HasInteractions;
Expand Down Expand Up @@ -54,7 +55,7 @@
#[UseFactory(factoryClass: UserFactory::class)]
#[Table(name: 'users')]
#[Hidden('password', 'remember_token', 'email_verified_at')]
final class User extends Authenticatable implements FilamentUser, HasMedia, HasName
final class User extends Authenticatable implements FilamentUser, HasAvatar, HasMedia, HasName
{
use HasAddress;
/** @use HasFactory<UserFactory> */
Expand Down Expand Up @@ -113,10 +114,9 @@ public function canAccessPanel(Panel $panel): bool
};
}

public function getFilamentAvatarUrl(): string
public function getFilamentAvatarUrl(): ?string
{

return sprintf('https://github.com/%s.png', $this->username);
return $this->getFirstMediaUrl('avatar') ?: null;
}

/**
Expand Down
8 changes: 8 additions & 0 deletions app/Providers/Filament/AdminPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Enums\FilamentPanel;
use App\Filament\Pages\Login;
use App\Http\Middleware\SetApplicationLocale;
use Filament\Actions\Action;
use Filament\Http\Middleware\Authenticate;
use Filament\Http\Middleware\AuthenticateSession;
use Filament\Http\Middleware\DisableBladeIconComponents;
Expand All @@ -15,6 +16,7 @@
use Filament\PanelProvider;
use Filament\Support\Colors\Color;
use He4rt\PanelAdmin\Pages\Dashboard;
use He4rt\PanelApp\Pages\ProfilePage;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Foundation\Http\Middleware\PreventRequestForgery;
Expand Down Expand Up @@ -60,6 +62,12 @@ public function panel(Panel $panel): Panel
->pages([
Dashboard::class,
])
->userMenuItems([
'profile' => fn (Action $action): Action => $action
->label(__('app.user_menu.my_profile'))
->url(ProfilePage::getUrl(panel: FilamentPanel::App->value))
->icon(icon: null),
])
->authMiddleware([
Authenticate::class,
]);
Expand Down
7 changes: 7 additions & 0 deletions app/Providers/Filament/AppPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Enums\FilamentPanel;
use App\Http\Middleware\SetApplicationLocale;
use Filament\Actions\Action;
use Filament\Http\Middleware\Authenticate;
use Filament\Http\Middleware\AuthenticateSession;
use Filament\Http\Middleware\DisableBladeIconComponents;
Expand Down Expand Up @@ -55,6 +56,12 @@ public function panel(Panel $panel): Panel
ThreadPage::class,
ProfilePage::class,
])
->userMenuItems([
'profile' => fn (Action $action): Action => $action
->label(__('app.user_menu.my_profile'))
->url(ProfilePage::getUrl())
->icon(icon: null),
])
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
Expand Down
4 changes: 4 additions & 0 deletions lang/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
'portuguese' => 'Português (Brasil)',
'portuguese_short' => 'PT-BR',
],

'user_menu' => [
'my_profile' => 'My profile',
],
];
4 changes: 4 additions & 0 deletions lang/pt_BR/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
'portuguese' => 'Português (Brasil)',
'portuguese_short' => 'PT-BR',
],

'user_menu' => [
'my_profile' => 'Meu perfil',
],
];
Loading