<?php

namespace App\Domains\Admin\Controllers;

use App\Models\Tenant;
use App\Scopes\CommonController;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class TenantCreateController extends CommonController
{
    public function __invoke(Request $request): JsonResponse
    {
        $tenant = Tenant::create([
            'name' => $request->input('name'),
            'slug' => $request->input('slug'),
            'url' => $request->input('url'),
            'email' => '',
            'email_finance' => '',
            'account_name' => '',
            'account_iban' => '',
            'account_bic' => '',
            'city' => '',
            'postcode' => '',
            'is_active_local_group' => true,
            'has_active_instance' => true,
        ]);

        return response()->json([
            'status' => 'success',
            'message' => 'Stamm wurde angelegt.',
            'slug' => $tenant->slug,
        ]);
    }
}
