Skip to content

Commit

Permalink
Merge pull request #193 from hellboy1975/166-custom-profile-component
Browse files Browse the repository at this point in the history
166 custom profile component
  • Loading branch information
hellboy1975 authored Mar 3, 2024
2 parents 49e8b93 + 9b3a2f9 commit 903c15a
Show file tree
Hide file tree
Showing 5 changed files with 452 additions and 397 deletions.
32 changes: 32 additions & 0 deletions app/Livewire/PilsiProfileComponent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Livewire;

use Filament\Forms\Components\Group;
use Filament\Forms\Components\TextInput;
use Jeffgreco13\FilamentBreezy\Livewire\PersonalInfo;

class PilsiProfileComponent extends PersonalInfo
{
public array $only = ['name', 'email', 'location'];

protected function getProfileFormSchema()
{
$groupFields = Group::make([
$this->getNameComponent(),
$this->getEmailComponent(),
$this->getLocationComponent(),
])->columnSpan(2);

return ($this->hasAvatars)
? [filament('filament-breezy')->getAvatarUploadComponent(), $groupFields]
: [$groupFields];
}

protected function getLocationComponent(): TextInput
{
return TextInput::make('location')
->required()
->label(__('Location'));
}
}
10 changes: 10 additions & 0 deletions app/Pages/PilsiProfilePage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Pages;

use Jeffgreco13\FilamentBreezy\Pages\MyProfilePage;

class PilsiProfilePage extends MyProfilePage
{
protected static ?string $navigationIcon = 'heroicon-o-user';
}
10 changes: 8 additions & 2 deletions app/Providers/Filament/AdminPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace App\Providers\Filament;

use App\Livewire\PilsiProfileComponent;
use App\Pages\PilsiProfilePage as PagesPilsiProfilePage;
use Awcodes\FilamentGravatar\GravatarPlugin;
use Awcodes\FilamentGravatar\GravatarProvider;
use Filament\Http\Middleware\Authenticate;
Expand Down Expand Up @@ -76,9 +78,13 @@ public function panel(Panel $panel): Panel
shouldRegisterUserMenu: true, // Sets the 'account' link in the panel User Menu (default = true)
shouldRegisterNavigation: true, // Adds a main navigation item for the My Profile page (default = false)
navigationGroup: 'Settings', // Sets the navigation group for the My Profile page (default = null)
hasAvatars: true, // Enables the avatar upload form component (default = false)
hasAvatars: false, // Enables the avatar upload form component (default = false)
slug: 'profile' // Sets the slug for the profile page (default = 'my-profile')
),
)
->myProfileComponents([
'personal_info' => PilsiProfileComponent::class,
])
->customMyProfilePage(PagesPilsiProfilePage::class),
])
->navigationGroups([
'My PilSi',
Expand Down
Loading

0 comments on commit 903c15a

Please sign in to comment.