Eloquent model returns 0 as primary key
You can also set the type of primary key:
protected $keyType = 'string';
public $incrementing = false;
Important note. You should add the second line. $incrementing = false
. If you do not this, the key will be 0 after calling save()
on your model.
You can try setting public $incrementing = false;
on your model so eloquent doesn't expect your primary key to be an autoincrement primary key.