BF model methods

This commit is contained in:
Fabian @ Blax Software 2026-05-18 08:16:09 +02:00
parent 1ed301b759
commit 0bb3b63a32
2 changed files with 6 additions and 2 deletions

View File

@ -243,7 +243,9 @@ class Cart extends Model
public function getTotal(): float
{
return $this->items()->sum('subtotal');
// SQL SUM of an integer column comes back as a numeric string under
// mysql's PDO driver — cast to honor the declared float return type.
return (float) $this->items()->sum('subtotal');
}
public function getTotalItems(): int

View File

@ -107,7 +107,9 @@ class ProductCategory extends Model
// Backward compatibility accessor
public function getIsVisibleAttribute(): bool
{
return $this->attributes['is_visible'] ?? true;
// Raw `$attributes['is_visible']` is a tinyint string under PDO mysql.
// Cast to bool to honor the declared return type (strict types).
return (bool) ($this->attributes['is_visible'] ?? true);
}
public function getProductCountAttribute(): int