This commit is contained in:
baodev0
2026-09-23 15:17:18 +07:00
parent cd38c5d6d0
commit 82a71244ca
107 changed files with 3332 additions and 3306 deletions
@@ -43,6 +43,27 @@ class SettingController extends Controller
]);
}
/**
* GET /settings/public
* Không cần token — chỉ trả các field công khai dùng cho trang đăng nhập.
*/
public function public(): JsonResponse
{
$setting = Setting::where('key', 'setting')->first();
$value = $setting ? json_decode((string) $setting->value, true) : [];
return response()->json([
'error' => false,
'data' => [
'title' => $value['title'] ?? '',
'company' => $value['company'] ?? '',
'logo' => $value['logo'] ?? '',
'favi_icon' => $value['favi_icon'] ?? '',
'brand_color' => $value['brand_color'] ?? '',
],
]);
}
/**
* PUT /administrator/settings
* Accepts: { setting: {...}, smtp: {...} }
@@ -105,6 +126,43 @@ class SettingController extends Controller
]);
}
/**
* GET /administrator/vat-settings
* Returns saved VAT rates per service type.
*/
public function vatIndex(): JsonResponse
{
$row = Setting::where('key', 'vat_settings')->first();
$data = $row ? json_decode((string) $row->value, true) : [];
return response()->json(['error' => false, 'data' => is_array($data) ? $data : []]);
}
/**
* PUT /administrator/vat-settings
* Accepts: { settings: [{ type, type_label, vat_rate }] }
*/
public function vatUpdate(Request $request): JsonResponse
{
$validator = Validator::make($request->all(), [
'settings' => 'required|array',
'settings.*.type' => 'required|string',
'settings.*.type_label' => 'sometimes|string|nullable',
'settings.*.vat_rate' => 'required|numeric|min:0|max:100',
]);
if ($validator->fails()) {
return response()->json(['error' => true, 'message' => $validator->errors()->first()], 422);
}
Setting::updateOrCreate(
['key' => 'vat_settings'],
['value' => json_encode($request->input('settings'), JSON_UNESCAPED_UNICODE)]
);
return response()->json(['error' => false, 'message' => 'Cập nhật thuế VAT thành công.']);
}
/**
* POST /administrator/settings/test-telegram
* Sends a test message using the currently saved Telegram config.