ApplyUpdateRequest.php 701 Bytes
<?php

namespace App\Http\Container\ManageSection\Requests\Audition;

use App\Enums\ActivityAuditStatusEnum;
use Hikoon\LaravelApi\Exceptions\ValidationException;
use Hikoon\LaravelApi\Support\ApiCode;

class ApplyUpdateRequest extends ApplyCreateRequest
{
    protected function prepareForValidation(): void
    {
        parent::prepareForValidation();

        $apply = $this->route('apply');

        if ($apply?->getAttribute('audit_status') !== ActivityAuditStatusEnum::FAIL->value) {
            throw new ValidationException(ApiCode::VALIDATION_ERROR, $apply->getAttribute('audit_status') === ActivityAuditStatusEnum::SUCCESS->value ? '审核已通过' : '审核进行中');
        }
    }
}