feature/handle-promotions #59
@@ -8,18 +8,19 @@ use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
final class PromosController extends BaseController
|
||||
{
|
||||
#[Route('/promos', name: 'app_promos')]
|
||||
public function __invoke(): Response
|
||||
#[Route('/promos/{promo?}', name: 'app_promos')]
|
||||
public function __invoke(?string $promo): Response
|
||||
{
|
||||
if($this->cache->getItem('list_promos')->isHit()) {
|
||||
return $this->render('productList.html.twig', ['listType' => 'promos']);
|
||||
return $this->render('productList.html.twig', ['listType' => 'promos'.urlencode($promo)]);
|
||||
}
|
||||
|
||||
$products = Product::whereRaw('priceCurrent < productStandardPrice')
|
||||
->orderByDesc('starred')
|
||||
->orderByDesc('created_by')
|
||||
->with(['currentPrice', 'lowestPrice'])
|
||||
->when(!is_null($promo) , fn ($q) => $q->whereRaw("json_extract(promotions, '$.tag') LIKE ?", $promo))
|
||||
->get();
|
||||
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'promos']);
|
||||
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'promos'.urlencode($promo)]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<td>
|
||||
<a href='{{ path('app_product', {'productId': product.id}) }}' class="text-decoration-none">{{ product.name }}</a>
|
||||
<span class="badge text-bg-light"><a 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 %}<span class="badge bg-info">PROMO: {{ product.promotions.tag }}</span>{% endif %}
|
||||
{% if product.promotions is not null and product.promotions.hasPromotion %}<a href="{{ path('app_promos', {'promo': product.promotions.tag}) }}"><span class="badge bg-info">PROMO: {{ product.promotions.tag }}</span></a>{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<nav aria-label="breadcrumb" style="--bs-breadcrumb-divider: '>';">
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<span class="badge text-bg-light"><a
|
||||
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 %}<span class="badge bg-info">PROMO: {{ product.promotions.tag }}</span>{% endif %}
|
||||
{% if product.promotions is not null and product.promotions.hasPromotion %}<a href="{{ path('app_promos', {'promo': product.promotions.tag}) }}"><span class="badge bg-info">PROMO: {{ product.promotions.tag }}</span></a>{% endif %}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<nav aria-label="breadcrumb" style="--bs-breadcrumb-divider: '>';">
|
||||
|
||||
Reference in New Issue
Block a user