<?php

namespace App\Domains\Admin\Controllers;

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

class TenantGeneralUpdateController extends CommonController
{
    public function __invoke(string $slug, Request $request): JsonResponse
    {
        $tenant = Tenant::where('slug', $slug)->firstOrFail();

        $tenant->update([
            'name' => $request->input('name'),
            'slug' => $request->input('slug'),
            'url' => $request->input('url'),
        ]);

        return response()->json([
            'status' => 'success',
            'message' => 'Allgemeine Daten wurden gespeichert.',
        ]);
    }
}
