<?php

namespace App\Http\Controllers\Api\V1;

use App\Helpers\ApiResponse;
use App\Http\Controllers\Controller;
use App\Http\Requests\RegisterRequest;
use App\Services\RegisterService;

class RegisterController extends Controller
{
    /**
     * Register a new user with tenant creation
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function register(RegisterRequest $request)
    {
        return ApiResponse::handle(function () use ($request) {
            return RegisterService::register($request->validated());
        }, __('message.registered'));
    }
}
