Skip to content
Advertisement

Is having an “id” column in a table mandatory to work with BackPack?

I have a table with columns color_id and list_id. When I load a page with that specific model in Laravel BackPack, it throws an error:

JavaScript

In general, this is correct. I do not have an id column since it’s a pivot table. I assumed adding custom sorting would solve the problem so I added the following line in my controller’s setup() method:

JavaScript

This didn’t solve the problem and BackPack is still trying to search id column.

JavaScript

Is there no way around it? Do I really need to add an id column to my table?

Advertisement

Answer

By adding this to my model, I was able to solve it for the moment:

protected $primaryKey = 'color_id';

But is this really the only solution?

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement