Temp.php
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace App\Console\Commands\Test;
use App\Helper\Arr;
use App\Models\Collect\CollectTask;
use App\Models\Com\UpdateLog;
use App\Models\Product\Product;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class Temp extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'test_temp';
/**
* The console command description.
*
* @var string
*/
protected $description = '临时脚本';
public function handle()
{
$data_project = [162];
foreach ($data_project as $project_id) {
$project = ProjectServer::useProject($project_id);
if ($project) {
$list = Product::get();
foreach ($list as $item) {
$seo = $item->seo_mate;
if ($seo) {
$seo['title'] = substr(strip_tags($seo['title']??''), 0, 70);
$seo['keyword'] = substr(strip_tags($seo['keyword']??''), 0, 255);
$seo['description'] = substr(strip_tags($seo['description']??''), 0, 200);
$item->seo_mate = Arr::a2s($seo);
try {
$item->save();
}catch (\Exception $e){
continue;
}
}
}
}
//关闭数据库
DB::disconnect('custom_mysql');
echo $project_id . '成功, product' . PHP_EOL;
}
}
}