Commit 3e82a44a by Angel MAS

contador de items

parent e2341cce
<?php
namespace Onestartup\Shop\Libs;
class Util
{
public function countCart()
{
$contador = 0;
if (\Session::has('cart')) {
$cart = \Session::get('cart');
foreach ($cart as $item) {
$contador = $contador + $item->quantity;
}
}
return $contador;
}
}
...@@ -7,9 +7,12 @@ ...@@ -7,9 +7,12 @@
@include('shop-public::metatags') @include('shop-public::metatags')
</head> </head>
<body> <body>
@php
$util = new Onestartup\Shop\Libs\Util();
@endphp
<p> <p>
<a href="{{route('cart.show')}}">Ver carrito <a href="{{route('cart.show')}}">Ver carrito
<span>{{\Session::has('cart') ? count(\Session::get('cart')) : 0}}</span> <span>{{$util->countCart()}} </span>
</a> </a>
</p> </p>
{{-- Aqui toda la estructura del blog--}} {{-- Aqui toda la estructura del blog--}}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment