حوّل البيانات باستخدام الموصلات والمحوّلات:
الموصل الحديث
protected function fullName(): Attribute
{
return Attribute::make(
get: fn () => "{$this->first_name} {$this->last_name}",
);
}المحوّل
protected function password(): Attribute
{
return Attribute::make(
set: fn ($value) => bcrypt($value),
);
}مدمج
protected function email(): Attribute
{
return Attribute::make(
get: fn ($value) => strtolower($value),
set: fn ($value) => strtolower($value),
);
}