feat(website-extras): enhance toggle functionality and update related tests; add additional info configuration to tenant extras

This commit is contained in:
2026-08-03 09:10:50 -03:00
parent f1df6a5918
commit 4a51f3afde
10 changed files with 134 additions and 17 deletions

View File

@@ -65,7 +65,10 @@ class WebsiteExtraController extends Controller
return WebsiteExtrasResource::make(
$this->loadTenant($request->user())
);
)->additional([
'code' => 'tenant.website_extra_toggled',
'message' => __('api.tenant.website_extra_toggled'),
]);
}
private function loadTenant(User $user): Tenant

View File

@@ -174,7 +174,15 @@ class WebsiteExtraService
$websiteExtra = $tenant->websiteExtras()
->where('website_type_extra_id', $definition->id)
->lockForUpdate()
->firstOrFail();
->first();
if (! $websiteExtra) {
return $tenant->websiteExtras()->create([
'website_type_extra_id' => $definition->id,
'config' => [],
'is_enabled' => true,
]);
}
$websiteExtra->update([
'is_enabled' => ! $websiteExtra->is_enabled,