From 10cd2c59a36ecf8ed5eab7f56437bf7960bc4df5 Mon Sep 17 00:00:00 2001 From: Krzysiej Date: Sun, 22 Feb 2026 09:37:19 +0100 Subject: [PATCH] Add countries selector --- src/Twig/AppExtension.php | 7 +++++++ templates/template.html.twig | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php index 22bc991..f165e79 100644 --- a/src/Twig/AppExtension.php +++ b/src/Twig/AppExtension.php @@ -3,6 +3,7 @@ namespace Krzysiej\RyobiCrawler\Twig; use Illuminate\Database\Eloquent\Collection; +use Krzysiej\RyobiCrawler\Models\Country; use Krzysiej\RyobiCrawler\Models\Price; use Krzysiej\RyobiCrawler\Models\Product; use Krzysiej\RyobiCrawler\Models\Stock; @@ -28,6 +29,7 @@ class AppExtension extends AbstractExtension new TwigFunction('discontinuedCount', [$this, 'discontinuedCount']), new TwigFunction('lowestPriceCount', [$this, 'lowestPriceCount']), new TwigFunction('renderCategoryTree', [$this, 'renderCategoryTree']), + new TwigFunction('getCountries', [$this, 'getCountries']), ]; } @@ -66,6 +68,11 @@ class AppExtension extends AbstractExtension ->count(); } + public function getCountries(): array + { + return Country::get()->toArray(); + } + public function findByCreatedAtDate(Collection $items, string $date): Stock|Price|null { return $items->first(fn($item) => str_starts_with($item->created_at, $date)); diff --git a/templates/template.html.twig b/templates/template.html.twig index 875b5b9..26b6292 100644 --- a/templates/template.html.twig +++ b/templates/template.html.twig @@ -33,6 +33,16 @@ +