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

pnoeric's avatar

Laravel Nova showing no data - related to table name/field names?

Hmm I'm not sure what's wrong, I JUST started with Laravel Nova and I can't get it to display my users table. :-(

The Eloquent model for Users is set up correctly; in tinker I can enter User::first() and that works fine. I see data, it's all good. (In fact I have seeded the table fully using standard Laravel factory/seeder procedure.)

But the screen is totally blank in the interface. I see rows and each of them just has a '-'. Clicking the "view" icon on any row returns a 404.

In my Nova/User.php file, I have public static $model = \App\Models\User::class; which is correct.

I suspect this is related to my non-standard table and column names. (Yes I know that's not fun, and no I can't change them; I'm forced to use an existing DB structure.)

But again, my Eloquent model is set up correctly (specifying the correct DB $table in the model so it functions). And in the Nova/User resource file, I've even simplified things so I can just see a list of IDs:

    public function fields(Request $request)
    {
        return [
            ID::make()->sortable(),
        ];
    }

The ID column in my db is named 'ID' (caps) and I've specified that in the Eloquent model (protected $primaryKey = 'ID';).

Help :-(

0 likes
2 replies
pnoeric's avatar

And, I was able to fix it by changing this:

    public function fields(Request $request)
    {
        return [
            ID::make('ID', 'ID')->sortable(),
        ];
    }

So... two questions:

  1. I assume this is an issue because my ID column is uppercase in the DB schema instead of lowercase. Is there a more better way to go about this? (No way Nova can just grab the name of the ID column from the db?)

  2. More importantly: I am concerned about having DB column names and table names in two different places (my Laravel User resource as well as my main Eloquent User model). To add the 'Email' field, I already had to change this chunk of code:

            Text::make('Email', 'Email')
                ->sortable()
                ->rules('required', 'email', 'max:254')
                ->creationRules('unique:myCustomUsersTable,email')
                ->updateRules('unique:myCustomUsersTable,email,{{resourceId}}'),

It just seems very... bad... to have something like the table name buried in a string in a PHP method call (where even phpStorm can't see it for refactoring). Is there any elegant way to get around this?

piljac1's avatar

Regarding your first question, I agree that it would be logical that Nova would take the redefined primary key into account, but there are a lot of things that Nova doesn't do as of today. However, it is based on Laravel and Laravel has its clear and defined database naming conventions, so I can understand that they automatically snake case names (if you don't define the second parameter).

As for your second remark, I understand the concern, however Nova wouldn't know what you want to add in your ressource because some column values should only be set programatically (without a user interface). So I hardly see how it would be logical that Nova somehow automatically add any new column to the ressource (if I understood what you desire correctly).

Please or to participate in this conversation.