Tenant management
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagedTenantContactGetController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = Tenant::where('slug', $slug)->firstOrFail();
|
||||
|
||||
return response()->json([
|
||||
'email' => $tenant->email,
|
||||
'email_finance' => $tenant->email_finance,
|
||||
'postcode' => $tenant->postcode,
|
||||
'city' => $tenant->city,
|
||||
'saveEndpoint' => '/api/v1/admin/tenants/' . $slug . '/contact',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagedTenantContactUpdateController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = Tenant::where('slug', $slug)->firstOrFail();
|
||||
|
||||
$tenant->update([
|
||||
'email' => $request->input('email'),
|
||||
'email_finance' => $request->input('email_finance'),
|
||||
'postcode' => $request->input('postcode'),
|
||||
'city' => $request->input('city'),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Kontaktdaten wurden gespeichert.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagedTenantGdprGetController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = Tenant::where('slug', $slug)->firstOrFail();
|
||||
|
||||
return response()->json([
|
||||
'gdpr_text' => $tenant->gdpr_text ?? '',
|
||||
'saveEndpoint' => '/api/v1/admin/tenants/' . $slug . '/gdpr',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagedTenantGdprUpdateController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = Tenant::where('slug', $slug)->firstOrFail();
|
||||
|
||||
$tenant->update([
|
||||
'gdpr_text' => $request->input('gdpr_text'),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Datenschutzerklärung wurde gespeichert.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagedTenantImpressGetController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = Tenant::where('slug', $slug)->firstOrFail();
|
||||
|
||||
return response()->json([
|
||||
'impress_text' => $tenant->impress_text ?? '',
|
||||
'saveEndpoint' => '/api/v1/admin/tenants/' . $slug . '/impress',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagedTenantImpressUpdateController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = Tenant::where('slug', $slug)->firstOrFail();
|
||||
|
||||
$tenant->update([
|
||||
'impress_text' => $request->input('impress_text'),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Impressum wurde gespeichert.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagedTenantPaymentGetController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = Tenant::where('slug', $slug)->firstOrFail();
|
||||
|
||||
return response()->json([
|
||||
'account_iban' => $tenant->account_iban,
|
||||
'account_bic' => $tenant->account_bic,
|
||||
'account_name' => $tenant->account_name,
|
||||
'saveEndpoint' => '/api/v1/admin/tenants/' . $slug . '/payment',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagedTenantPaymentUpdateController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = Tenant::where('slug', $slug)->firstOrFail();
|
||||
|
||||
$tenant->update([
|
||||
'account_iban' => $request->input('account_iban'),
|
||||
'account_bic' => $request->input('account_bic'),
|
||||
'account_name' => $request->input('account_name'),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Bezahldaten wurden gespeichert.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ class TenantContactGetController extends CommonController
|
||||
'email_finance' => $this->tenant->email_finance,
|
||||
'postcode' => $this->tenant->postcode,
|
||||
'city' => $this->tenant->city,
|
||||
'saveEndpoint' => '/api/v1/admin/tenant/contact',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Providers\InertiaProvider;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Response;
|
||||
|
||||
class TenantEditPageController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): Response
|
||||
{
|
||||
$tenant = Tenant::where('slug', $slug)->firstOrFail();
|
||||
|
||||
$inertiaProvider = new InertiaProvider('Admin/TenantEdit', [
|
||||
'tenant' => [
|
||||
'name' => $tenant->name,
|
||||
'slug' => $tenant->slug,
|
||||
'url' => $tenant->url,
|
||||
'is_active_local_group' => $tenant->is_active_local_group,
|
||||
],
|
||||
]);
|
||||
return $inertiaProvider->render();
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ class TenantGdprGetController extends CommonController
|
||||
{
|
||||
return response()->json([
|
||||
'gdpr_text' => $this->tenant->gdpr_text ?? '',
|
||||
'saveEndpoint' => '/api/v1/admin/tenant/gdpr',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TenantGeneralGetController extends CommonController
|
||||
{
|
||||
public function __invoke(string $slug, Request $request): JsonResponse
|
||||
{
|
||||
$tenant = Tenant::where('slug', $slug)->firstOrFail();
|
||||
|
||||
return response()->json([
|
||||
'name' => $tenant->name,
|
||||
'slug' => $tenant->slug,
|
||||
'url' => $tenant->url,
|
||||
'is_active_local_group' => $tenant->is_active_local_group,
|
||||
'saveEndpoint' => '/api/v1/admin/tenants/' . $slug . '/general',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?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.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ class TenantImpressGetController extends CommonController
|
||||
{
|
||||
return response()->json([
|
||||
'impress_text' => $this->tenant->impress_text ?? '',
|
||||
'saveEndpoint' => '/api/v1/admin/tenant/impress',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TenantListApiController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
$tenants = Tenant::where('has_active_instance', true)->get()->map(function ($tenant) {
|
||||
return [
|
||||
'name' => $tenant->name,
|
||||
'slug' => $tenant->slug,
|
||||
'url' => $tenant->url,
|
||||
'is_active_local_group' => $tenant->is_active_local_group,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json(['tenants' => $tenants]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Admin\Controllers;
|
||||
|
||||
use App\Providers\InertiaProvider;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Response;
|
||||
|
||||
class TenantListPageController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): Response
|
||||
{
|
||||
$inertiaProvider = new InertiaProvider('Admin/TenantList', []);
|
||||
return $inertiaProvider->render();
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ class TenantPaymentGetController extends CommonController
|
||||
'account_iban' => $this->tenant->account_iban,
|
||||
'account_bic' => $this->tenant->account_bic,
|
||||
'account_name' => $this->tenant->account_name,
|
||||
'saveEndpoint' => '/api/v1/admin/tenant/payment',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user