BF model methods
This commit is contained in:
parent
1ed301b759
commit
0bb3b63a32
|
|
@ -243,7 +243,9 @@ class Cart extends Model
|
||||||
|
|
||||||
public function getTotal(): float
|
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
|
public function getTotalItems(): int
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,9 @@ class ProductCategory extends Model
|
||||||
// Backward compatibility accessor
|
// Backward compatibility accessor
|
||||||
public function getIsVisibleAttribute(): bool
|
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
|
public function getProductCountAttribute(): int
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue