|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @remark :
|
|
|
|
* @name :PopularTemplateLabel.php
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/6/3 17:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Console\Commands\TemplateLabel;
|
|
|
|
|
|
|
|
use App\Models\Template\Template;
|
|
|
|
use App\Models\Template\TemplateLabel as TemplateLabelModel;
|
|
|
|
use App\Models\Template\TemplateModule;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
|
|
class PopularTemplateLabel extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $signature = 'popular_template_label';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = '设置热门label';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :执行脚本
|
|
|
|
* @name :handle
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/6/3 17:01
|
|
|
|
*/
|
|
|
|
public function handle(){
|
|
|
|
$this->setTemplate();
|
|
|
|
$this->setTemplateModule();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :公共模块热门模块
|
|
|
|
* @name :setTemplate
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/6/3 15:56
|
|
|
|
*/
|
|
|
|
public function setTemplate(){
|
|
|
|
$templateModel = new Template();
|
|
|
|
$info = $templateModel->list(['test_model'=>0],'number',['id'],'desc',50);
|
|
|
|
if(empty($info)){
|
|
|
|
return true;
|
|
|
|
}else{
|
|
|
|
//清除当前所有最新标签
|
|
|
|
$labelModel = new TemplateLabelModel();
|
|
|
|
$labelModel->del(['name'=>'热门','type'=>1]);
|
|
|
|
$data = [];
|
|
|
|
foreach ($info as $v){
|
|
|
|
$data[] = [
|
|
|
|
'name'=>'热门',
|
|
|
|
'type'=>1,
|
|
|
|
'template_id'=>$v['id'],
|
|
|
|
'manager_id'=>0,
|
|
|
|
'created_at'=>date('Y-m-d H:i:s'),
|
|
|
|
'updated_at'=>date('Y-m-d H:i:s')
|
|
|
|
];
|
|
|
|
}
|
|
|
|
//设置为最新
|
|
|
|
$labelModel->insert($data);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :左侧模块
|
|
|
|
* @name :templateModule
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/6/3 15:54
|
|
|
|
*/
|
|
|
|
public function setTemplateModule(){
|
|
|
|
$templateModuleModel = new TemplateModule();
|
|
|
|
$moduleInfo = $templateModuleModel->list(['test_model'=>0],'id',['id']);
|
|
|
|
if(empty($moduleInfo)){
|
|
|
|
return true;
|
|
|
|
}else{
|
|
|
|
//清除当前所有最新标签
|
|
|
|
$labelModel = new TemplateLabelModel();
|
|
|
|
$labelModel->del(['name'=>'热门','type'=>2]);
|
|
|
|
$moduleData = [];
|
|
|
|
foreach ($moduleInfo as $k => $v){
|
|
|
|
$moduleData[] = [
|
|
|
|
'name'=>'热门',
|
|
|
|
'type'=>2,
|
|
|
|
'template_id'=>$v['id'],
|
|
|
|
'manager_id'=>0,
|
|
|
|
'created_at'=>date('Y-m-d H:i:s'),
|
|
|
|
'updated_at'=>date('Y-m-d H:i:s')
|
|
|
|
];
|
|
|
|
}
|
|
|
|
//设置为最新
|
|
|
|
$labelModel->insert($moduleData);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
...
|
...
|
|