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'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -126,11 +126,11 @@ class FileService
|
||||
$errors = [];
|
||||
|
||||
if (! in_array($file->getMimeType(), $this->allowedMimes)) {
|
||||
$errors['file'] = __('File type :type is not allowed. Allowed: jpg, png, pdf, mp4, mov.', ['type' => $file->getMimeType()]);
|
||||
$errors['file'] = __('feedback.file_type_not_allowed', ['type' => $file->getMimeType()]);
|
||||
}
|
||||
|
||||
if ($file->getSize() > $this->maxSize * 1024) {
|
||||
$errors['file'] = __('File size exceeds :max KB.', ['max' => $this->maxSize]);
|
||||
$errors['file'] = __('feedback.file_size_exceeds', ['max' => $this->maxSize]);
|
||||
}
|
||||
|
||||
if (! empty($errors)) {
|
||||
|
||||
@@ -10,9 +10,6 @@ use Illuminate\Validation\ValidationException;
|
||||
|
||||
class TransferService
|
||||
{
|
||||
/**
|
||||
* Transfer a feedback to another department.
|
||||
*/
|
||||
public function transfer(
|
||||
Feedback $feedback,
|
||||
Department $toDepartment,
|
||||
@@ -22,7 +19,7 @@ class TransferService
|
||||
): TicketTransferLog {
|
||||
if (empty(trim($reason))) {
|
||||
throw ValidationException::withMessages([
|
||||
'reason' => __('Vui lòng nhập lý do chuyển tiếp.'),
|
||||
'reason' => __('feedback.transfer_reason_required'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user