Start working on filtering by country
All checks were successful
/ deploy-job (push) Successful in 0s
All checks were successful
/ deploy-job (push) Successful in 0s
This commit is contained in:
25
src/Controller/CountryController.php
Normal file
25
src/Controller/CountryController.php
Normal 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']);
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@
|
||||
href="{{ path('app_search', {'search': product.subTitle}) }}"
|
||||
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 %}
|
||||
<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 class="align-middle">
|
||||
<nav aria-label="breadcrumb" style="--bs-breadcrumb-divider: '>';">
|
||||
|
||||
Reference in New Issue
Block a user