feat: ship creator journey v2 and profile updates
This commit is contained in:
@@ -17,6 +17,27 @@ class Category extends Model
|
||||
|
||||
protected $casts = ['is_active' => 'boolean'];
|
||||
|
||||
public function getNameAttribute(?string $value): ?string
|
||||
{
|
||||
return self::decodeHtmlEntities($value);
|
||||
}
|
||||
|
||||
public function setNameAttribute(?string $value): void
|
||||
{
|
||||
$normalized = self::decodeHtmlEntities($value);
|
||||
$this->attributes['name'] = $normalized !== null ? trim($normalized) : null;
|
||||
}
|
||||
|
||||
public function getDescriptionAttribute(?string $value): ?string
|
||||
{
|
||||
return self::decodeHtmlEntities($value);
|
||||
}
|
||||
|
||||
public function setDescriptionAttribute(?string $value): void
|
||||
{
|
||||
$this->attributes['description'] = self::decodeHtmlEntities($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure slug is always lowercase and valid before saving.
|
||||
*/
|
||||
@@ -159,4 +180,25 @@ class Category extends Model
|
||||
|
||||
return $category;
|
||||
}
|
||||
|
||||
private static function decodeHtmlEntities(?string $value): ?string
|
||||
{
|
||||
if ($value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$decoded = $value;
|
||||
|
||||
for ($index = 0; $index < 5; $index++) {
|
||||
$next = html_entity_decode($decoded, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
|
||||
if ($next === $decoded) {
|
||||
break;
|
||||
}
|
||||
|
||||
$decoded = $next;
|
||||
}
|
||||
|
||||
return $decoded;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user