Skip to content

specify $keyType = 'string' if keytype is not int #307

@wivaku

Description

@wivaku

[Similar to #233 , but more generic]

If the primary key is not int it should be explicitly defined.
The explicit keytype is needed because Eloquent queries will otherwise assume the key is int.

For tables where the primary key is not integer, set:
public $keyType = 'string';

It already sets the following:
public $incrementing = false;

$body .= $this->class->field('incrementing', false, ['visibility' => 'public']);

It already detects if the primary key is not int:

public function hasCustomPrimaryKeyCast()

It detects the keytype, but not sure if we can / need to use that value.
I believe it can always be set to string if the primary key is not int.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions