mirror of
https://github.com/jez500/pricebuddy.git
synced 2026-11-24 19:58:13 +01:00
36 lines
787 B
PHP
36 lines
787 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Product;
|
|
use Illuminate\Console\Command;
|
|
|
|
class RegeneratePriceCache extends Command
|
|
{
|
|
const COMMAND = 'buddy:regenerate-price-cache';
|
|
|
|
/**
|
|
* The name and signature of the console command.
|
|
*/
|
|
protected $signature = self::COMMAND;
|
|
|
|
/**
|
|
* The console command description.
|
|
*/
|
|
protected $description = 'Regenerate product price cache';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle()
|
|
{
|
|
Product::all()
|
|
->each(fn (Product $product) => $this->components->task(
|
|
'(ID: '.$product->getKey().') '.$product->title_short,
|
|
fn () => $product->updatePriceCache())
|
|
);
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|