Files
portal-api/app/Http/Controllers/Api/Setting/SettingController.php
T
baodev0andClaude Opus 5.5 bf78f3b810 feat: hồ sơ khách (ngày sinh, tỉnh/phường theo mã), gộp menu + nút tắt, thông báo theo uuid
- PUT v1/client/update: gender theo enum ClientGender (0 Nam/1 Nữ), thêm
  birthday (cột mới), province_code/ward_code validate theo bảng provinces/wards
  (phường phải thuộc tỉnh). Migration nạp dữ liệu hành chính 2025 từ
  province_ward_import.sql (chỉ bảng trống), API GET v1/provinces[/{code}/wards].
- CustomerObserver/OrderObserver log giá trị cũ bằng getRawOriginal: getOriginal
  trả enum object, nối chuỗi gây 500 khi khách đổi giới tính.
- ClientResource: các cờ trả boolean, CCCD chỉ trả cccd_updated (không lộ ảnh/số).
- GET v1/setting/menu trả cả items + quick_links, bỏ v1/setting/quick-links.
- Thông báo admin/khách tra theo uuid thay vì id tự tăng.
- Chặn gửi template marketing cho khách đã tắt nhận email marketing.
- Xoá ProvinceWardSeeder và Customer::$updatable không dùng.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 16:03:18 +07:00

85 lines
2.4 KiB
PHP

<?php
namespace App\Http\Controllers\Api\Setting;
use App\Http\Controllers\Controller;
use App\Models\PopupBanner;
use App\Models\Setting;
use App\Support\ClientMenu;
use App\Support\ClientQuickLinks;
use App\Support\PublicSetting;
use App\Support\Turnstile;
/**
* @OA\Tag(
* name="Settings",
* description="API Endpoints for Application Settings"
* )
*/
class SettingController extends Controller
{
/**
* @OA\Get(
* path="/setting",
* operationId="getSetting",
* tags={"Settings"},
* summary="Get application settings",
* description="Returns the public application settings (title, company, logo, favi_icon, brand_color)",
* @OA\Response(
* response=200,
* description="Successful operation",
* @OA\JsonContent(
* @OA\Property(property="data", type="object"),
* @OA\Property(property="message", type="string", example="Get setting successfully"),
* @OA\Property(property="error", type="boolean", example=false)
* )
* )
* )
*/
public function getSetting(): \Illuminate\Http\JsonResponse
{
return response()->json([
'data' => PublicSetting::values(),
'message' => 'Get setting successfully',
'error' => false
]);
}
public function getEmailSetting(): \Illuminate\Http\JsonResponse
{
$setting = Setting::where('key', 'email_settings')->first();
$value = $setting ? json_decode($setting->value, true) : [];
return response()->json([
'error' => false,
'data' => [
'mail_enabled' => $value['mail_enabled'] ?? true,
],
]);
}
public function getTurnstileSetting(): \Illuminate\Http\JsonResponse
{
return response()->json([
'error' => false,
'data' => ['site_key' => Turnstile::siteKey()],
]);
}
public function getMenu(): \Illuminate\Http\JsonResponse
{
return response()->json([
'error' => false,
'data' => [
'items' => ClientMenu::items(),
'quick_links' => ClientQuickLinks::items(),
],
]);
}
public function getPopups(): \Illuminate\Http\JsonResponse
{
return response()->json(['error' => false, 'data' => PopupBanner::publicList()]);
}
}