Files
postshop-backend/app/Console/Commands/SyncProductPropertiesJson.php
Mekan1206 c46eccb24f Refactor code for improved readability and consistency
- Removed unnecessary blank lines in various files to enhance code clarity.
- Updated comments for consistency and clarity across multiple classes and methods.
- Adjusted spacing in test files for better formatting and readability.
2026-02-08 02:24:43 +05:00

48 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Models\Ecommerce\Product\Product\Product;
use Illuminate\Console\Command;
class SyncProductPropertiesJson extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'products:sync-properties-json';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Syncs all product properties to the new JSON column';
/**
* Execute the console command.
*/
public function handle()
{
$this->info('Starting sync of product properties JSON...');
// Using cursor to be memory efficient
$products = Product::cursor();
$count = Product::count();
$bar = $this->output->createProgressBar($count);
$bar->start();
foreach ($products as $product) {
$product->syncPropertiesJson();
$bar->advance();
}
$bar->finish();
$this->newLine();
$this->info('Sync completed successfully!');
}
}