Search code examples
laravelmodel

Laravel Model primary key change error Illegal offset type


The illegal offset type shows this error when

protected $primaryKey = ['user_id'];
public $incrementing = false;

Solution

  • The primaryKey takes a string not array all you need is to change it to string

    protected $primaryKey = 'user_id';