<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Http\Requests\Auth\RegisterLeasingRequest;
use App\Services\RegistrationService;
use Illuminate\Support\Facades\Auth;

class RegisterLeasingController extends Controller
{
    protected $service;

    public function __construct(RegistrationService $service)
    {
        $this->service = $service;
    }

    public function create()
    {
        return view('auth.register-leasing');
    }

    public function store(RegisterLeasingRequest $request)
    {
        $user = $this->service->registerLeasing($request->validated());
        Auth::login($user);
        return redirect()->route('dashboard')->with('success', 'Registrasi berhasil! Selamat datang di ekosistem Leasing Pro. Silakan pilih paket untuk memulai.');
    }
}
