© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
20 replies
Debjit

Custom Group Label

I am working on a Laravel Filament project and I have a problem with grouping a resource by blood group. I have an array that maps blood group ids to blood group names, like this:
$bloodGroups = [
    1 => 'A+',
    2 => 'B+',
    3 => 'AB+',
    4 => 'O+',
    5 => 'A-',
    6 => 'B-',
    7 => 'AB-',
    8 => 'O-'
];
$bloodGroups = [
    1 => 'A+',
    2 => 'B+',
    3 => 'AB+',
    4 => 'O+',
    5 => 'A-',
    6 => 'B-',
    7 => 'AB-',
    8 => 'O-'
];

I store the blood group id as an integer in the database, but I want to display the blood group name in the resource. However, when I use the groups method, it shows the id instead of the name, like this:
->groups([
    'required_on',
    'blood_group', // this shows the id, not the name
])
->groups([
    'required_on',
    'blood_group', // this shows the id, not the name
])

For example, it shows "Blood group: 1" instead of "Blood group: A+". How can I fix this?
image.png
Solution
If you put them in a table, then you can use:
https://filamentphp.com/docs/3.x/tables/grouping#setting-a-grouping-label

Else, remove the interfers and just create string array of groups and ensure the users enter as a string and not a number.
Grouping rows - Table Builder - Filament
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

summarizer group label
FilamentFFilament / ❓┊help
2y ago
Extend group action label
FilamentFFilament / ❓┊help
3mo ago
Navigation group without label
FilamentFFilament / ❓┊help
3y ago
Navigation group translated label and sort
FilamentFFilament / ❓┊help
17mo ago