<?php

namespace App\Http\Controllers\API\v1\PortalSettings;

use App\Http\Controllers\Controller;
use App\Models\PortalSetting;

class GetController extends Controller
{
    public function __invoke()
    {
        $setting = PortalSetting::singleton();
        $defaults = PortalSetting::defaults();

        return response()->json([
            'status' => 'success',
            'data' => [
                'updated_at' => optional($setting->updated_at)->toIso8601String(),
                'home_mat_label' => $setting->home_mat_label ?? $defaults['home_mat_label'],
                'home_banner_image_path' => $setting->home_banner_image_path ?? $defaults['home_banner_image_path'],
                'zoom_meeting_label' => $setting->zoom_meeting_label ?? $defaults['zoom_meeting_label'],
                'zoom_subtitle' => $setting->zoom_subtitle ?? $defaults['zoom_subtitle'],
                'zoom_image_url' => $setting->zoom_image_url ?? $defaults['zoom_image_url'],
                'zoom_meeting_url' => $setting->zoom_meeting_url ?? $defaults['zoom_meeting_url'],
                'attendance_etika_url' => $setting->attendance_etika_url ?? $defaults['attendance_etika_url'],
            ],
        ]);
    }
}

