mirror of
https://github.com/wearepixel/laravel-cart.git
synced 2026-11-14 13:51:44 +00:00
23 lines
490 B
PHP
23 lines
490 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Wearepixel\Cart\Concerns;
|
|
|
|
use Wearepixel\Cart\Cart;
|
|
|
|
class ShareCartWithInertia
|
|
{
|
|
public static function data(?Cart $cart = null): array
|
|
{
|
|
$cart ??= app('cart');
|
|
|
|
return [
|
|
'items' => $cart->getContent()->toArray(),
|
|
'subtotal' => (float) $cart->getSubTotal(false),
|
|
'total' => (float) $cart->getTotal(),
|
|
'count' => (int) $cart->getTotalQuantity(),
|
|
];
|
|
}
|
|
}
|