Start working on filtering by country
All checks were successful
/ deploy-job (push) Successful in 0s

This commit is contained in:
2026-02-21 08:40:07 +01:00
parent ad0ef20fc2
commit 810643c18a
2 changed files with 26 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
<?php
namespace Krzysiej\RyobiCrawler\Controller;
use Illuminate\Database\Eloquent\Builder;
use Krzysiej\RyobiCrawler\Models\Product;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
final class CountryController extends BaseController
{
#[Route('/country/{country?}', name: 'app_country')]
public function __invoke(?string $country): Response
{
/** @var Product[] $products */
$products = Product::with(['price', 'lowestPrice', 'country'])
->join('countries', 'countries.id', '=', 'products.country_id')
->where('countryName', $country)
->orderByDesc('starred')
->orderByDesc('created_by')
->get();
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'country']);
}
}

View File

@@ -63,7 +63,7 @@
href="{{ path('app_search', {'search': product.subTitle}) }}" href="{{ path('app_search', {'search': product.subTitle}) }}"
class="link-underline link-underline-opacity-0 link-dark">{{ product.subTitle }}</a></span> class="link-underline link-underline-opacity-0 link-dark">{{ product.subTitle }}</a></span>
{% if product.promotions is not null and product.promotions.hasPromotion %}<a href="{{ path('app_promos', {'promo': product.promotions.slug}) }}"><span class="badge bg-info">PROMO: {{ product.promotions.tag }}</span></a>{% endif %} {% if product.promotions is not null and product.promotions.hasPromotion %}<a href="{{ path('app_promos', {'promo': product.promotions.slug}) }}"><span class="badge bg-info">PROMO: {{ product.promotions.tag }}</span></a>{% endif %}
<span class="badge text-bg-light">{{ product.country.countryName }}</span> <span class="badge text-bg-light"><a href="{{ path('app_country', {'country': product.country.countryName}) }}" class="link-underline link-underline-opacity-0 link-dark">{{ product.country.countryName }}</a></span>
</td> </td>
<td class="align-middle"> <td class="align-middle">
<nav aria-label="breadcrumb" style="--bs-breadcrumb-divider: '>';"> <nav aria-label="breadcrumb" style="--bs-breadcrumb-divider: '>';">