class Student extends BaseModel (View source)

Represents a student with encrypted personal information (CPF, email, phone).

Provides relationships to loans and school classes.

Properties

bool $incrementing

Indicates that the model does not use auto-incrementing IDs.

from  BaseModel
protected string $keyType

The data type of the primary key ID.

from  BaseModel
bool $timestamps

Indicates if the model should not use timestamps.

protected string $table

The database table associated with the model.

protected array<int,string> $fillable

The attributes that are mass assignable.

protected array<int,string> $hidden

The attributes that should be hidden for serialization.

Methods

string|null
getIdAttribute(mixed $value)

Converts the binary UUID stored in the database into a string UUID.

static void
boot()

Boot function for the model.

void
setCpfAttribute(string $value)

Sets and encrypts the CPF, also stores its SHA-256 hash.

void
setEmailAttribute(string $value)

Sets and encrypts the email, also stores its SHA-256 hash.

void
setPhoneAttribute(string $value)

Sets and encrypts the phone number, also stores its SHA-256 hash.

string|null
getCpfAttribute(null|string $value)

Gets the decrypted CPF.

string|null
getEmailAttribute(null|string $value)

Gets the decrypted email.

string|null
getPhoneAttribute(null|string $value)

Gets the decrypted phone number, formatted if possible.

HasMany
loans()

Relationship: Student has many loans.

BelongsToMany
schoolClasses()

Relationship: Student belongs to many school classes.

Details

string|null getIdAttribute(mixed $value)

Converts the binary UUID stored in the database into a string UUID.

Parameters

mixed $value

binary value from the database

Return Value

string|null

UUID in string format, or null if not set

static protected void boot()

Boot function for the model.

This ensures that every new record automatically gets a UUID assigned if no ID is provided during creation.

Return Value

void

void setCpfAttribute(string $value)

Sets and encrypts the CPF, also stores its SHA-256 hash.

Parameters

string $value

Plain CPF

Return Value

void

void setEmailAttribute(string $value)

Sets and encrypts the email, also stores its SHA-256 hash.

Parameters

string $value

Plain email

Return Value

void

void setPhoneAttribute(string $value)

Sets and encrypts the phone number, also stores its SHA-256 hash.

Parameters

string $value

Plain phone

Return Value

void

string|null getCpfAttribute(null|string $value)

Gets the decrypted CPF.

Parameters

null|string $value

Encrypted CPF

Return Value

string|null

Decrypted CPF

string|null getEmailAttribute(null|string $value)

Gets the decrypted email.

Parameters

null|string $value

Encrypted email

Return Value

string|null

Decrypted email

string|null getPhoneAttribute(null|string $value)

Gets the decrypted phone number, formatted if possible.

Parameters

null|string $value

Encrypted phone

Return Value

string|null

Formatted phone

HasMany loans()

Relationship: Student has many loans.

Return Value

HasMany

BelongsToMany schoolClasses()

Relationship: Student belongs to many school classes.

Return Value

BelongsToMany