<?php

namespace App\Http\Controllers\Auth;

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

class RegisterMemberController extends Controller
{
    protected $service;

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

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

    public function store(RegisterMemberRequest $request)
    {
        $user = $this->service->registerMember($request->validated());
        Auth::login($user);
        return redirect()->route('dashboard');
    }
}
