UpdateSeoTdkCrontab.php 1.0 KB
<?php

namespace App\Console\Commands\Tdk;

use App\Models\Project\Project;
use App\Models\Project\ProjectUpdateTdk;
use Illuminate\Console\Command;

/**
 * 初始化项目
 * Class InitProject
 * @package App\Console\Commands
 * @author zbj
 * @date 2023/10/8
 */
class UpdateSeoTdkCrontab extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'update_seo_tdk_crontab';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '一键生成tdk';

    /**
     * @return bool
     */
    public function handle()
    {
        $project_ids = Project::where('type', Project::TYPE_TWO)->where('uptime', '<=', date('Y-m-d H:i:s'))->pluck('id')->toArray();
        foreach ($project_ids as $project_id){
            try {
                ProjectUpdateTdk::add_task($project_id);
            }catch (\Exception $e){
                dump($e->getMessage());
            }
        }
    }

}