feature/lowest-price #27
@@ -15,7 +15,7 @@ final class CategoryController extends BaseController
|
|||||||
return $this->render('productList.html.twig', ['listType' => 'category_'.$category]);
|
return $this->render('productList.html.twig', ['listType' => 'category_'.$category]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$products = Product::with('price')
|
$products = Product::with(['price', 'lowestPrice'])
|
||||||
->selectRaw('products.*')
|
->selectRaw('products.*')
|
||||||
->distinct('products.id')
|
->distinct('products.id')
|
||||||
->fromRaw('products, json_each(products.categories)')
|
->fromRaw('products, json_each(products.categories)')
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ final class DiscontinuedController extends BaseController
|
|||||||
$products = Product::where('updated_at', '<', now()->format('Y-m-d'))
|
$products = Product::where('updated_at', '<', now()->format('Y-m-d'))
|
||||||
->orderByDesc('starred')
|
->orderByDesc('starred')
|
||||||
->orderByDesc('created_by')
|
->orderByDesc('created_by')
|
||||||
->with(['currentPrice'])
|
->with(['currentPrice', 'lowestPrice'])
|
||||||
->get();
|
->get();
|
||||||
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'discontinued']);
|
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'discontinued']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ final class IndexController extends BaseController
|
|||||||
#[Route('/', name: 'app_home')]
|
#[Route('/', name: 'app_home')]
|
||||||
public function __invoke(): Response
|
public function __invoke(): Response
|
||||||
{
|
{
|
||||||
// if($this->cache->getItem('list_all')->isHit()) {
|
if ($this->cache->getItem('list_all')->isHit()) {
|
||||||
// return $this->render('productList.html.twig', ['listType' => 'all']);
|
return $this->render('productList.html.twig', ['listType' => 'all']);
|
||||||
// }
|
}
|
||||||
$products = Product::with(['currentStock', 'price', 'lowestPrice'])
|
$products = Product::with(['currentStock', 'price', 'lowestPrice'])
|
||||||
->orderByDesc('starred')
|
->orderByDesc('starred')
|
||||||
->orderByDesc('created_by')
|
->orderByDesc('created_by')
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ final class NewController extends BaseController
|
|||||||
$products = Product::where('created_at', '>', now()->modify('-30 days')->format('Y-m-d'))
|
$products = Product::where('created_at', '>', now()->modify('-30 days')->format('Y-m-d'))
|
||||||
->orderByDesc('starred')
|
->orderByDesc('starred')
|
||||||
->orderByDesc('created_by')
|
->orderByDesc('created_by')
|
||||||
->with(['currentPrice'])
|
->with(['currentPrice', 'lowestPrice'])
|
||||||
->get();
|
->get();
|
||||||
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'new']);
|
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'new']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ final class PromosController extends BaseController
|
|||||||
$products = Product::whereHas('currentPrice', fn(Builder $query) => $query->whereColumn('price', '<', 'productStandardPrice'))
|
$products = Product::whereHas('currentPrice', fn(Builder $query) => $query->whereColumn('price', '<', 'productStandardPrice'))
|
||||||
->orderByDesc('starred')
|
->orderByDesc('starred')
|
||||||
->orderByDesc('created_by')
|
->orderByDesc('created_by')
|
||||||
->with(['currentPrice'])
|
->with(['currentPrice', 'lowestPrice'])
|
||||||
->get();
|
->get();
|
||||||
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'promos']);
|
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'promos']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Categories</th>
|
<th>Categories</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th>Price</th>
|
<th class="text-end">Lowest Price</th>
|
||||||
|
<th class="text-end">Current Price</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -45,8 +46,8 @@
|
|||||||
</nav>
|
</nav>
|
||||||
</td>
|
</td>
|
||||||
<td class="align-middle"><a href='https://pl.ryobitools.eu/{{ product.url }}'>link</a></td>
|
<td class="align-middle"><a href='https://pl.ryobitools.eu/{{ product.url }}'>link</a></td>
|
||||||
<td class="align-middle">{{ product.price.last.price | format_currency('PLN', {}, 'pl') }}</td>
|
<td class="align-middle text-end">{% if product.lowestPrice.price != product.price.last.price %}{{ product.lowestPrice.price | format_currency('PLN', {}, 'pl') }}{% endif %}</td>
|
||||||
<td class="align-middle">{{ product.lowestPrice.price | format_currency('PLN', {}, 'pl') }}</td>
|
<td class="align-middle text-end">{{ product.price.last.price | format_currency('PLN', {}, 'pl') }}</td>
|
||||||
<td class="align-middle">
|
<td class="align-middle">
|
||||||
<div class="d-flex flex-row">
|
<div class="d-flex flex-row">
|
||||||
{% if product.price.last.price != product.price.last.productStandardPrice %}<span
|
{% if product.price.last.price != product.price.last.productStandardPrice %}<span
|
||||||
|
|||||||
Reference in New Issue
Block a user