<?php

namespace App\Http\Controllers\Leasing;

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

class ProfileController extends Controller
{
    public function edit()
    {
        $profile = auth()->user()->leasingProfile;
        return view('leasing.profile.edit', compact('profile'));
    }

    public function update(Request $request)
    {
        $profile = auth()->user()->leasingProfile;

        $validated = $request->validate([
            'company_name' => 'required|string|max:255',
            'address' => 'nullable|string',
            'phone' => 'nullable|string|max:20',
        ]);

        $profile->update($validated);

        return back()->with('success', 'Profil perusahaan berhasil diperbarui.');
    }
}
