Custom filament page route for change password
I created a custom filament page using this https://filamentphp.com/docs/2.x/admin/resources/custom-pages
And added to appserviceprovider boot. I call the Resource URL with the following. I also added the page in the resource getPages().
use Filament\Facades\Filament;
use Filament\Navigation\UserMenuItem;
Filament::serving(function () {
Filament::registerUserMenuItems([
UserMenuItem::make()
->label('Change Password')
->url(UserResource::getUrl('changePassword'))
->icon('heroicon-s-cog'),
]);
});
I get error
Route [filament.resources.users.changePassword] not defined.
How do I register the route?
Filament
Custom pages - Resources - Admin Panel - Filament
The elegant TALL stack admin panel for Laravel artisans.
Solution:Jump to solution
Okay I finally got it, it is because I cache the URL, after I clear cache it works.
3 Replies
Can you share your
UserResource
?class UserResource extends Resource
{
protected static ?string $model = User::class;
protected static ?string $navigationIcon = 'heroicon-o-users';
protected static ?string $activeNavigationIcon = 'heroicon-s-users';
protected static ?string $navigationGroup = 'Administration';
public static function form(Form $form): Form
{
return $form
->schema([
//
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('name'),
TextColumn::make('email'),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
]);
}
public static function getRelations(): array { return [
]; }
public static function getPages(): array { return [ 'index' => Pages\ListUsers::route('/'), 'create' => Pages\CreateUser::route('/create'), 'edit' => Pages\EditUser::route('/{record}/edit'), 'changePassword' => Pages\ChangePassword::route('/change-password'), ]; } @pboivin I' still havent solved this 😦
public static function getRelations(): array { return [
]; }
public static function getPages(): array { return [ 'index' => Pages\ListUsers::route('/'), 'create' => Pages\CreateUser::route('/create'), 'edit' => Pages\EditUser::route('/{record}/edit'), 'changePassword' => Pages\ChangePassword::route('/change-password'), ]; } @pboivin I' still havent solved this 😦
Solution
Okay I finally got it, it is because I cache the URL, after I clear cache it works.