feat: add i18n support for Vietnamese and English
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

This commit is contained in:
2026-05-04 10:40:39 +00:00
parent 3a8db5cae6
commit 8c6b71cb8a
64 changed files with 4652 additions and 254 deletions

View File

@@ -11,25 +11,22 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
class ClosingService
{
/**
* Close a feedback. Throws if staff tries to close or no proof exists.
*/
public function close(Feedback $feedback, User $actor): void
{
if ($feedback->status === 'closed') {
throw ValidationException::withMessages([
'status' => __('Phiếu này đã được đóng.'),
'status' => __('feedback.already_closed'),
]);
}
if (! $actor->hasPermissionTo('close-ticket')) {
throw new HttpException(403, __('Chỉ lãnh đạo cấp phòng mới có quyền đóng phiếu.'));
throw new HttpException(403, __('feedback.close_permission_denied'));
}
if ($actor->hasRole('manager') && ! $actor->hasRole('admin')) {
$managedDeptIds = Department::where('manager_id', $actor->id)->pluck('id');
if (! $managedDeptIds->contains($feedback->current_department_id)) {
throw new HttpException(403, __('Bạn chỉ có thể đóng phiếu thuộc phòng ban mình quản lý.'));
throw new HttpException(403, __('feedback.close_department_only'));
}
}
@@ -37,7 +34,7 @@ class ClosingService
if (! $fileService->hasCollection($feedback, 'proof_of_resolution')) {
throw ValidationException::withMessages([
'status' => __('Yêu cầu cung cấp tài liệu bằng chứng để hoàn tất quy trình.'),
'status' => __('feedback.proof_required'),
]);
}
@@ -46,14 +43,11 @@ class ClosingService
$this->notifyStakeholders($feedback, $actor);
}
/**
* Resolve a feedback. Any role can resolve.
*/
public function resolve(Feedback $feedback, User $actor): void
{
if (in_array($feedback->status, ['closed', 'resolved'])) {
throw ValidationException::withMessages([
'status' => __('Phiếu này đã được xử lý hoặc đóng.'),
'status' => __('feedback.already_resolved'),
]);
}