<?php

namespace App\Services\Violation;

use App\Models\Media\MediaSecure;
use App\Models\PartnerModel;
use App\Models\User\UserModel;
use App\Services\User\PartnerService;

class Voice extends ViolationAbstract
{

    public function handle()
    {
        $this->user = UserModel::find($this->media->uid);
        $partner = PartnerModel::whereRaw($this->media->field_primary)->first();
        switch ($this->media->result) {
            case MediaSecure::MANUAL_SUGGESTION_BLOCK:
                $this->handleFailed($partner->id);
                break;
            case MediaSecure::MANUAL_SUGGESTION_PASS:
                $this->handleSuccess($partner->id);
                break;
        }
    }

    public function handleFailed($partnerId)
    {
        $userService = new PartnerService();
        $userService->check($partnerId, 'voice_check', -1);
    }

    public function handleSuccess($partnerId)
    {
        $userService = new PartnerService();
        $userService->check($partnerId, 'voice_check', 1);
    }
}
