<?php

namespace App\Console\Commands\ContentManage;

use http\Exception\RuntimeException;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
use Modules\Common\Errors\Errors;
use Modules\Common\Exceptions\CommonBusinessException;

class ContentTest extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'app:contenttest';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     */
    public function handle(): void
    {
       $result = DB::table('promotions')
           ->where(['puid' => 0])
           ->get();
       foreach ($result as $item) {
           DB::table('promotions')
               ->where('id', $item->id)
               ->update([
                   'puid' => DB::table('users')->where('id', $item->uid)->value('pid')
               ]);
       }
    }
}