mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-11-30 22:20:45 +00:00
50 lines
1018 B
PHP
50 lines
1018 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Console\Commands;
|
||
|
|
|
||
|
|
use App\Models\GoodsSku;
|
||
|
|
use Illuminate\Console\Command;
|
||
|
|
|
||
|
|
class UpdateGoodsSkuName extends Command
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* The name and signature of the console command.
|
||
|
|
*
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
protected $signature = 'update:goods_skus:name';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The console command description.
|
||
|
|
*
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
protected $description = '更新goods_sku的完整名称';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Create a new command instance.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function __construct()
|
||
|
|
{
|
||
|
|
parent::__construct();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Execute the console command.
|
||
|
|
*/
|
||
|
|
public function handle()
|
||
|
|
{
|
||
|
|
GoodsSku::query()
|
||
|
|
->where('name', '')
|
||
|
|
->where('is_combination', 0)
|
||
|
|
->chunk(500, static function ($skus) {
|
||
|
|
foreach ($skus as $sku) {
|
||
|
|
$sku->name = $sku->goods->title . $sku->title;
|
||
|
|
$sku->save();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|