feature/handle-promotions (#59)

Reviewed-on: #59
Co-authored-by: Krzysiej <krzysiej@gmail.com>
Co-committed-by: Krzysiej <krzysiej@gmail.com>
This commit was merged in pull request #59.
This commit is contained in:
2026-02-04 08:35:16 +01:00
committed by krzysiej
parent 6556ba0f88
commit a545bfe2ab
6 changed files with 44 additions and 7 deletions

View File

@@ -181,6 +181,11 @@ class Migrate extends Command
$table->integer('stock')->nullable();
});
}
if (!Capsule::schema()->hasColumn('products', 'promotions')) {
Capsule::schema()->table('products', function (Blueprint $table) {
$table->json('promotions')->nullable();
});
}
}
public function index(): void

View File

@@ -120,6 +120,7 @@ class ScrapeWebsite extends Command
$productModel->lastSeen = date("Y-m-d");
$productModel->touch('updated_at');
$productModel->country()->associate($country);
$productModel->promotions = $product->promotions;
$productModel->save();
$priceExists = $productModel->price()->whereRaw("strftime('%Y-%m-%d', created_at) = ?", [date('Y-m-d')])->exists();