This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
namespace Krzysiej\RyobiCrawler\Twig;
|
namespace Krzysiej\RyobiCrawler\Twig;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Krzysiej\RyobiCrawler\Models\Country;
|
||||||
use Krzysiej\RyobiCrawler\Models\Price;
|
use Krzysiej\RyobiCrawler\Models\Price;
|
||||||
use Krzysiej\RyobiCrawler\Models\Product;
|
use Krzysiej\RyobiCrawler\Models\Product;
|
||||||
use Krzysiej\RyobiCrawler\Models\Stock;
|
use Krzysiej\RyobiCrawler\Models\Stock;
|
||||||
@@ -28,6 +29,7 @@ class AppExtension extends AbstractExtension
|
|||||||
new TwigFunction('discontinuedCount', [$this, 'discontinuedCount']),
|
new TwigFunction('discontinuedCount', [$this, 'discontinuedCount']),
|
||||||
new TwigFunction('lowestPriceCount', [$this, 'lowestPriceCount']),
|
new TwigFunction('lowestPriceCount', [$this, 'lowestPriceCount']),
|
||||||
new TwigFunction('renderCategoryTree', [$this, 'renderCategoryTree']),
|
new TwigFunction('renderCategoryTree', [$this, 'renderCategoryTree']),
|
||||||
|
new TwigFunction('getCountries', [$this, 'getCountries']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +68,11 @@ class AppExtension extends AbstractExtension
|
|||||||
->count();
|
->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCountries(): array
|
||||||
|
{
|
||||||
|
return Country::get()->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
public function findByCreatedAtDate(Collection $items, string $date): Stock|Price|null
|
public function findByCreatedAtDate(Collection $items, string $date): Stock|Price|null
|
||||||
{
|
{
|
||||||
return $items->first(fn($item) => str_starts_with($item->created_at, $date));
|
return $items->first(fn($item) => str_starts_with($item->created_at, $date));
|
||||||
|
|||||||
@@ -33,6 +33,16 @@
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link {% if app.request.pathinfo == path('app_discontinued') %}active shadow-sm bg-body rounded{% endif %}" aria-current="page" href="{{ path('app_discontinued') }}">Discontinued <span class="badge text-bg-secondary">{{ discontinuedCount() }}</span></a>
|
<a class="nav-link {% if app.request.pathinfo == path('app_discontinued') %}active shadow-sm bg-body rounded{% endif %}" aria-current="page" href="{{ path('app_discontinued') }}">Discontinued <span class="badge text-bg-secondary">{{ discontinuedCount() }}</span></a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item dropdown">
|
||||||
|
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
|
Countries
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
{% for country in getCountries() %}
|
||||||
|
<li><a class="dropdown-item" href="{{ path('app_country', {'country': country.countryName}) }}">{{ country.countryName }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<form class="form-floating d-flex col-lg-6 col-sm-8" role="search" action="{{ path('app_search') }}">
|
<form class="form-floating d-flex col-lg-6 col-sm-8" role="search" action="{{ path('app_search') }}">
|
||||||
|
|||||||
Reference in New Issue
Block a user