From a388b53cff22aa8e78d381d87035e72c61fb0f3c Mon Sep 17 00:00:00 2001 From: Krzysiej Date: Mon, 19 Jan 2026 08:33:19 +0100 Subject: [PATCH 01/23] Add the rest of available countries. --- src/Command/Migrate.php | 91 ++++++++++++++++++++++++++++++----------- 1 file changed, 67 insertions(+), 24 deletions(-) diff --git a/src/Command/Migrate.php b/src/Command/Migrate.php index 96880d5..1a6890c 100644 --- a/src/Command/Migrate.php +++ b/src/Command/Migrate.php @@ -6,6 +6,7 @@ namespace Krzysiej\RyobiCrawler\Command; use Illuminate\Database\Capsule\Manager as Capsule; use Illuminate\Database\Schema\Blueprint; +use Krzysiej\RyobiCrawler\Models\Country; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; @@ -93,26 +94,66 @@ class Migrate extends Command $table->timestamps(); }); } - $id = Capsule::table('countries')->insertGetId( - [ - 'countryName' => 'Poland', - 'productsUrl' => 'https://pl.ryobitools.eu/api/product-listing/get-products', - 'cultureCode' => 'pl-PL', - 'currency' => 'PLN', - 'locale' => 'pl', - 'created_at' => now(), - 'updated_at' => now(), - ]); - Capsule::table('countries')->insert([ - 'countryName' => 'UK', - 'productsUrl' => 'https://uk.ryobitools.eu/api/product-listing/get-products', - 'cultureCode' => 'en-GB', - 'currency' => 'GBP', - 'locale' => 'en', - 'created_at' => now(), - 'updated_at' => now(), - ] - ); + if (Capsule::schema()->hasTable('countries') && !Country::where('countryName', 'Poland')->exists()) { + $id = Capsule::table('countries')->insertGetId( + [ + 'countryName' => 'Poland', + 'productsUrl' => 'https://pl.ryobitools.eu/api/product-listing/get-products', + 'cultureCode' => 'pl-PL', + 'currency' => 'PLN', + 'locale' => 'pl', + 'created_at' => now(), + 'updated_at' => now(), + ]); + } + if (Capsule::schema()->hasTable('countries') && !Country::where('countryName', 'UK')->exists()) { + Capsule::table('countries')->insert([ + 'countryName' => 'UK', + 'productsUrl' => 'https://uk.ryobitools.eu/api/product-listing/get-products', + 'cultureCode' => 'en-GB', + 'currency' => 'GBP', + 'locale' => 'en', + 'created_at' => now(), + 'updated_at' => now(), + ] + ); + } + if (Capsule::schema()->hasTable('countries') && !Country::where('countryName', 'Netherlands')->exists()) { + Capsule::table('countries')->insert([ + 'countryName' => 'Netherlands', + 'productsUrl' => 'https://nl.ryobitools.eu/api/product-listing/get-products', + 'cultureCode' => 'nl-NL', + 'currency' => 'EUR', + 'locale' => 'nl', + 'created_at' => now(), + 'updated_at' => now(), + ] + ); + } + if (Capsule::schema()->hasTable('countries') && !Country::where('countryName', 'France')->exists()) { + Capsule::table('countries')->insert([ + 'countryName' => 'France', + 'productsUrl' => 'https://fr.ryobitools.eu/api/product-listing/get-products', + 'cultureCode' => 'fr-FR', + 'currency' => 'EUR', + 'locale' => 'fr', + 'created_at' => now(), + 'updated_at' => now(), + ] + ); + } + if (Capsule::schema()->hasTable('countries') && !Country::where('countryName', 'Spain')->exists()) { + Capsule::table('countries')->insert([ + 'countryName' => 'Spain', + 'productsUrl' => 'https://es.ryobitools.eu/api/product-listing/get-products', + 'cultureCode' => 'es-ES', + 'currency' => 'EUR', + 'locale' => 'es', + 'created_at' => now(), + 'updated_at' => now(), + ] + ); + } if (!Capsule::schema()->hasColumn('products', 'country_id')) { Capsule::schema()->table('products', function (Blueprint $table) use ($id) { @@ -174,9 +215,11 @@ class Migrate extends Command public function index(): void { - Capsule::schema()->table('products', function (Blueprint $table) { - $table->integer('skuID')->unique(false)->change(); - $table->unique(['skuID', 'country_id']); - }); + if (!count(Capsule::select('SELECT name FROM sqlite_master WHERE type = "index" and name = "products_skuid_country_id_unique"'))) { + Capsule::schema()->table('products', function (Blueprint $table) { + $table->integer('skuID')->unique(false)->change(); + $table->unique(['skuID', 'country_id']); + }); + } } } From 3bbf82f897e5558589b087949033db7bef619987 Mon Sep 17 00:00:00 2001 From: Krzysiej Date: Sun, 18 Jan 2026 10:13:56 +0100 Subject: [PATCH 02/23] Start working on handling multiple countries at once --- templates/product.html.twig | 2 +- templates/productList.html.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/product.html.twig b/templates/product.html.twig index a6ce4dc..bbf3147 100644 --- a/templates/product.html.twig +++ b/templates/product.html.twig @@ -10,7 +10,7 @@ {{ product.name }} {{ product.name }} - {{ product.subTitle }} + {{ product.subTitle }}