Add promotions to database and scrape command
This commit is contained in:
@@ -181,6 +181,11 @@ class Migrate extends Command
|
|||||||
$table->integer('stock')->nullable();
|
$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
|
public function index(): void
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ class ScrapeWebsite extends Command
|
|||||||
$productModel->lastSeen = date("Y-m-d");
|
$productModel->lastSeen = date("Y-m-d");
|
||||||
$productModel->touch('updated_at');
|
$productModel->touch('updated_at');
|
||||||
$productModel->country()->associate($country);
|
$productModel->country()->associate($country);
|
||||||
|
$productModel->promotions = json_encode($product->promotions);
|
||||||
$productModel->save();
|
$productModel->save();
|
||||||
$priceExists = $productModel->price()->whereRaw("strftime('%Y-%m-%d', created_at) = ?", [date('Y-m-d')])->exists();
|
$priceExists = $productModel->price()->whereRaw("strftime('%Y-%m-%d', created_at) = ?", [date('Y-m-d')])->exists();
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ use function Symfony\Component\Clock\now;
|
|||||||
* @property float $lowestProductPrice30Days
|
* @property float $lowestProductPrice30Days
|
||||||
* @property Date $lastSeen
|
* @property Date $lastSeen
|
||||||
* @property integer $stock
|
* @property integer $stock
|
||||||
|
* @property Object $promotions
|
||||||
*/
|
*/
|
||||||
class Product extends Model
|
class Product extends Model
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user