feat: add i18n support for Vietnamese and English
This commit is contained in:
@@ -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'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user