Change default primary key in Eloquent in Laravel
If you are wanting to use a composite key (a string)
You need to make sure you set public $incrementing = false
otherwise laravel will cast the field to an Integer, giving 0
class User extends Model {
protected $primaryKey = 'my_string_key';
public $incrementing = false;
}