Transform data with accessors and mutators:
Modern Accessor
protected function fullName(): Attribute
{
return Attribute::make(
get: fn () => "{$this->first_name} {$this->last_name}",
);
}Mutator
protected function password(): Attribute
{
return Attribute::make(
set: fn ($value) => bcrypt($value),
);
}Combined
protected function email(): Attribute
{
return Attribute::make(
get: fn ($value) => strtolower($value),
set: fn ($value) => strtolower($value),
);
}