Reputation: 2625
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:
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.
Upvotes: 1
Views: 622
Reputation: 2625
For some reason I interpreted from the documentation that I needed to rename all the id
columns to include the resource name, eg professions_id
.
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.
There was nothing to be found in the Laravel logs btw.
Upvotes: 1