From ebaee5f9fce257bc42cc6fc61833461f3f01fc2f Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Wed, 27 Mar 2024 14:58:15 +0000 Subject: [PATCH] [OLYMPUS-17]: Delete New Tenant on Advising App Dev --- .../Tenants/CreateTenantController.php | 9 +++- .../Tenants/DeleteTenantController.php | 47 +++++++++++++++++++ routes/landlord_api.php | 7 +++ 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 app/Http/Controllers/Tenants/DeleteTenantController.php diff --git a/app/Http/Controllers/Tenants/CreateTenantController.php b/app/Http/Controllers/Tenants/CreateTenantController.php index c0d8fa738c..d8b0f78008 100644 --- a/app/Http/Controllers/Tenants/CreateTenantController.php +++ b/app/Http/Controllers/Tenants/CreateTenantController.php @@ -36,6 +36,7 @@ namespace App\Http\Controllers\Tenants; +use Illuminate\Http\JsonResponse; use App\Multitenancy\Actions\CreateTenant; use App\Http\Requests\Tenants\CreateTenantRequest; use App\Multitenancy\DataTransferObjects\TenantUser; @@ -48,9 +49,9 @@ class CreateTenantController { - public function __invoke(CreateTenantRequest $request): void + public function __invoke(CreateTenantRequest $request): JsonResponse { - app(CreateTenant::class)( + $tenant = app(CreateTenant::class)( $request->validated('name'), $request->validated('domain'), new TenantConfig( @@ -106,5 +107,9 @@ public function __invoke(CreateTenantRequest $request): void password: $request->validated('user.password'), ), ); + + return response()->json(['tenant' => [ + 'id' => $tenant->getKey(), + ]]); } } diff --git a/app/Http/Controllers/Tenants/DeleteTenantController.php b/app/Http/Controllers/Tenants/DeleteTenantController.php new file mode 100644 index 0000000000..a21d0f4b1c --- /dev/null +++ b/app/Http/Controllers/Tenants/DeleteTenantController.php @@ -0,0 +1,47 @@ + + + Copyright © 2016-2024, Canyon GBS LLC. All rights reserved. + + Advising App™ is licensed under the Elastic License 2.0. For more details, + see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Advising App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + https://www.canyongbs.com or contact us via email at legal@canyongbs.com. + + +*/ + +namespace App\Http\Controllers\Tenants; + +use App\Models\Tenant; + +class DeleteTenantController +{ + public function __invoke(Tenant $tenant): void + { + $tenant->delete(); + } +} diff --git a/routes/landlord_api.php b/routes/landlord_api.php index a7a10d2222..b7e00cd29f 100644 --- a/routes/landlord_api.php +++ b/routes/landlord_api.php @@ -37,9 +37,16 @@ use Illuminate\Support\Facades\Route; use App\Http\Controllers\UpdateBrandSettingsController; use App\Http\Controllers\Tenants\CreateTenantController; +use App\Http\Controllers\Tenants\DeleteTenantController; Route::post('tenants', CreateTenantController::class) ->name('tenants.create'); +Route::delete('tenants/{tenant}', DeleteTenantController::class) + ->name('tenants.delete'); + Route::post('brand', UpdateBrandSettingsController::class) ->name('brand.update'); + +Route::post('test', fn () => true) + ->name('test');