Files
minicrm/app/Rules/RequireProofOfResolution.php
phuongtc 8c6b71cb8a
Some checks failed
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled
Tests / PHP 8.5 (push) Has been cancelled
feat: add i18n support for Vietnamese and English
2026-05-04 10:40:39 +00:00

33 lines
745 B
PHP

<?php
namespace App\Rules;
use App\Models\Feedback;
use App\Services\FileService;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Support\Facades\App;
class RequireProofOfResolution implements ValidationRule
{
protected Feedback $feedback;
public function __construct(Feedback $feedback)
{
$this->feedback = $feedback;
}
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if ($value !== 'closed') {
return;
}
$fileService = App::make(FileService::class);
if (! $fileService->hasCollection($this->feedback, 'proof_of_resolution')) {
$fail(__('feedback.proof_required'));
}
}
}