Sorry, I've read your code wrong. What's the schema for themes
table? Is code
primary key of themes
table?
Yes it is. code is the primary key for themes table and id is the primary key for the users table. the pivot table theme_user has user_id and theme_code as columns
Eloquent assumes the name of primary key is id
, in your case you need to specify primary key for Theme
model explicitly:
class Theme extends Model
{
protected $primaryKey = 'code';
...
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community