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 @@ +