<?php

namespace App\Http\Controllers;

use App\Models\Customer;
use Illuminate\Http\Request;

class CustomerPropertyInterestController extends Controller
{
    public function store(Request $request, Customer $customer)
    {
        $request->validate([
            'property_id' => 'required|exists:properties,id',
            'interest_level' => 'required|string|in:High,Medium,Low',
            'notes' => 'nullable|string',
        ]);

        $customer->propertyInterests()->syncWithoutDetaching([
            $request->property_id => [
                'interest_level' => $request->interest_level,
                'notes' => $request->notes,
            ]
        ]);

        return back()->with('success', 'Property interest recorded successfully.');
    }
}
