feat(website-extras): enhance toggle functionality and update related tests; add additional info configuration to tenant extras
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user