<?php

namespace App\Http\Controllers\Agency;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

use App\Models\Customer\CustomerFieldDefinition;
use App\Models\Customer\CustomerDocumentType;

class SettingsController extends Controller
{
    /**
     * Display the settings dashboard.
     */
    public function index()
    {
        $agencyId = auth()->user()->agency_id;

        $stats = [
            'custom_fields' => CustomerFieldDefinition::byAgency($agencyId)->count(),
            'active_custom_fields' => CustomerFieldDefinition::byAgency($agencyId)->active()->count(),
            'document_types' => CustomerDocumentType::byAgency($agencyId)->count(),
            'active_document_types' => CustomerDocumentType::byAgency($agencyId)->active()->count(),
        ];

        return view('agency.settings.index', compact('stats'));
    }

    /**
     * Update global agency settings.
     */
    public function update(Request $request)
    {
        // ... update logic ...
        return back()->with('success', 'Ayarlar güncellendi.');
    }
}
