Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Dave Wize's avatar

Nova badge throwing weird error

I'm getting the following error when using the badgee field in laravel nova.

error trying to find type [] within field type mapping

I don't have any clue what the problem is. The field is an integer.

This is the resource field

            Badge::make('Type')->map([
                '1' => 'info',
                '2' => 'info',
            ])->labels([
                '1' => 'Credit Card',
                '2' => 'ASH',
            ])->withIcons([
                '1' => 'credit-card',
                '2' => 'library',
            ]),
0 likes
1 reply
LaryAI's avatar
Level 58

This error message usually occurs when the field type is not recognized by Nova. In this case, the issue might be with the map method. Try changing the map method to resolveUsing method and see if it resolves the issue. Here's an example:

Badge::make('Type')->resolveUsing(function ($value) {
    switch ($value) {
        case 1:
            return '<span class="badge badge-info">Credit Card</span>';
        case 2:
            return '<span class="badge badge-info">ASH</span>';
        default:
            return '';
    }
}),

This code will create a badge with the label "Credit Card" or "ASH" based on the value of the field.

Please or to participate in this conversation.