From 7547478d4b6bc9170a3305441638735c4588e2ac Mon Sep 17 00:00:00 2001 From: Krzysiej Date: Tue, 20 Jan 2026 10:44:07 +0100 Subject: [PATCH] Improvements to handling countries. --- src/Command/ScrapeWebsite.php | 2 +- src/Controller/NewController.php | 6 +++--- src/Models/Product.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Command/ScrapeWebsite.php b/src/Command/ScrapeWebsite.php index 9993707..f68342e 100644 --- a/src/Command/ScrapeWebsite.php +++ b/src/Command/ScrapeWebsite.php @@ -113,7 +113,7 @@ class ScrapeWebsite extends Command $productModel->skuID = $product->skuID; $productModel->name = $product->name; $productModel->availableQuantity = $product->availableQuantity; - $productModel->categories = $product->categories; + $productModel->categories = str_replace(['/', ' '], '', $product->categories); $productModel->image = $product->image; $productModel->subTitle = $product->subTitle; $productModel->variantCode = $product->variantCode; diff --git a/src/Controller/NewController.php b/src/Controller/NewController.php index cf1f3ee..16d875b 100644 --- a/src/Controller/NewController.php +++ b/src/Controller/NewController.php @@ -16,11 +16,11 @@ final class NewController extends BaseController if($this->cache->getItem('list_new')->isHit()) { return $this->render('productList.html.twig', ['listType' => 'new']); } - - $products = Product::where('created_at', '>', now()->modify('-30 days')->format('Y-m-d')) + $date = now()->modify('-30 days')->format('Y-m-d'); + $products = Product::where('created_at', '>', $date) + ->with(['country', 'stock']) ->orderByDesc('starred') ->orderByDesc('created_by') - ->with(['currentPrice', 'lowestPrice']) ->get(); return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'new']); } diff --git a/src/Models/Product.php b/src/Models/Product.php index 139ddf9..eadb99c 100644 --- a/src/Models/Product.php +++ b/src/Models/Product.php @@ -31,7 +31,7 @@ use function Symfony\Component\Clock\now; class Product extends Model { public $timestamps = true; - public $fillable = ['skuID']; + public $fillable = ['skuID', 'country_id']; public function country(): BelongsTo {