diff --git a/src/Models/Cart.php b/src/Models/Cart.php index 94b9714..b2626b8 100644 --- a/src/Models/Cart.php +++ b/src/Models/Cart.php @@ -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 diff --git a/src/Models/ProductCategory.php b/src/Models/ProductCategory.php index 7aff318..fcfbda2 100644 --- a/src/Models/ProductCategory.php +++ b/src/Models/ProductCategory.php @@ -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