<?php

namespace App\Console\Commands\Pair;

use App\Models\Fpdx\PairModel;
use Illuminate\Console\Command;

class ExitGroupCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'pair:exit:group';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '退出群聊';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        //
//        $id = $this->ask('选择ID:');
        $service = new \App\Services\Pair\GroupService();

        $pairs = PairModel::where('stage_id', 55)
            ->where('rematch', 1)
            ->where('group_id', '>', 0)
            ->whereNotNull('assoc_id')
            ->get();
        foreach ($pairs as $pair) {
            $service->exitGroup($pair);
        }
    }
}
