BaseIdentifier trait adds random base64 identifiers to a model used as a random lookup key that is immune to enumeration attacks. The model is assumed to have the attribute: baseid.

Add this to your database table with:


Public Methods

public baseIdentifyAttributes()

public baseIdentifyAttributes(): void

public generateBaseIdentifier()

public generateBaseIdentifier(): void

generateBaseIdentifier returns a random encoded 64 bit number

public getBaseIdentifierColumnName()

public getBaseIdentifierColumnName(): string 

getBaseIdentifierColumnName gets the name of the "baseid" column.

public initializeBaseIdentifier()

public initializeBaseIdentifier(): void

initializeBaseIdentifier trait for a model.

Protected Methods

protected getBaseIdentifierUniqueAttributeValue()

protected getBaseIdentifierUniqueAttributeValue(string $name): string 

getBaseIdentifierUniqueAttributeValue ensures a unique attribute value, if the value is already used another base identifier is created. Returns a safe value that is unique.