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

MB's avatar
Level 2

DisplayUsing() not working with integers

Hi,

This stopped working after i changed the datatype to integer in my database. Why is that?

BelongsTo::make('Radio', 'gearratio', 'App\Nova\Gearratio')
    ->displayUsing(function ($name) {
        return 'i: '.$name;
    }),

Getting this error:

Object of class App\Nova\Gearratio could not be converted to string
0 likes
2 replies
mushood's avatar

Don't know Nova specifically BUT you might want to implement the following method in the Gearratio

public function __toString()
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Or simply tell it what to actually show

BelongsTo::make('Radio', 'gearratio', 'App\Nova\Gearratio')
    ->displayUsing(function ($name) {
        return 'i: '.$name->my_column;
    }),

Please or to participate in this conversation.