<?php

namespace App\Console\Commands\User;

use App\Jobs\StoreSelfPartnerJob;
use App\Models\Partner\ThumbActionModel;
use App\Models\User\UserModel;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class BugStorePartnerCommand extends Command
{
    protected $signature = "bug:storepartner";

    protected $description = "";

    public function handle()
    {
        $users = ThumbActionModel::where('thumb', 1)->select(DB::raw("DISTINCT(`uid`) as uid"))->get();
        foreach ($users as $user) {
            try {
                $um = UserModel::findOrFail($user->uid);
                if ($um->partner_id > 0) {
                    dump(StoreSelfPartnerJob::dispatch($um->uid));
                }
            } catch (\Exception $exception) {
            }
        }
    }
}
