diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php index 05e78c9..7eb9c02 100644 --- a/src/Twig/AppExtension.php +++ b/src/Twig/AppExtension.php @@ -19,6 +19,7 @@ class AppExtension extends AbstractExtension { return [ new TwigFunction('promosCount', [$this, 'promosCount']), + new TwigFunction('allCount', [$this, 'allCount']), new TwigFunction('newCount', [$this, 'newCount']), new TwigFunction('discontinuedCount', [$this, 'discontinuedCount']), ]; @@ -30,10 +31,14 @@ class AppExtension extends AbstractExtension new TwigFilter('findByCreatedAtDate', [$this, 'findByCreatedAtDate']), ]; } + public function allCount(): int + { + return Product::count(); + } public function promosCount(): int { - return Product::whereHas('currentPrice', fn(Builder $query) => $query->whereColumn('price', '<', 'productStandardPrice'))->with(['currentPrice'])->count(); + return Product::whereHas('currentPrice', fn(Builder $query) => $query->whereColumn('price', '<', 'productStandardPrice'))->count(); } public function newCount(): int diff --git a/templates/template.html.twig b/templates/template.html.twig index a5d1b08..3435816 100644 --- a/templates/template.html.twig +++ b/templates/template.html.twig @@ -18,6 +18,9 @@