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

AlexGodbehere79's avatar

Laravel nova 404 error

I have a resource called Professions where I've recently changed the column ID to profession_id because in the future I'll need a hasMany relationship.

Model:

class Profession extends Model
{
    protected $primaryKey = 'profession_id';
}

In the Nova resource:

public static $search = [
    'profession_id',
];

In the migration file:

$table->increments('profession_id');

I've ran php artisan migrate:refresh and all tables and columns are created correctly.

This is what happens:

  • When I create a profession, after pressing the 'Create Profession' button in Nova I get a 404. The profession is created however.
  • Listing, viewing and editing professions works fine

The weird thing is that if I edit a Profession and save it, it will go to the view page where the new Profession record is displayed. This is the exact same page where I should land if I press 'Create Profession', however that gives a 404.

I'm struggling here because the 404 doesn't give any info on where the error occurs.

0 likes
4 replies
tisuchi's avatar
tisuchi
Best Answer
Level 70

@alexgodbehere79

Have you renamed all the id columns to include the resource name, eg professions_id. I think it is required. Although make sure that you have changed that as described in the documentation.

It turns out that changing the column name is unnecessary, and actually creates this error. So leave them as id. Note that you can actually change column names, it's just that in this case (with Nova) it resulted in an error.

7 likes

Please or to participate in this conversation.