user()->stores()->where('slug', $slug)->firstOrFail(); abort_if($store->plan === null, 404); $rules = ['preset' => ['nullable', Rule::in(array_keys(PlanSchema::STYLE_PRESETS))], 'style' => ['nullable', 'array']]; foreach (PlanSchema::STYLE_OPTIONS as $option => $values) { $rules["style.$option"] = ['nullable', Rule::in($values)]; } $validated = $request->validate($rules); $plan = $store->plan; $preset = PlanSchema::STYLE_PRESETS[$validated['preset'] ?? ''] ?? null; if ($preset !== null) { $plan['theme']['radius'] = $preset['radius']; $plan['theme']['fonts'] = $preset['fonts']; $plan['theme']['style'] = $preset['style']; } if (is_array($validated['style'] ?? null)) { $plan['theme']['style'] = [...PlanSchema::STYLE_DEFAULTS, ...($plan['theme']['style'] ?? []), ...array_filter($validated['style'])]; } $store->plan = $validator->validate($plan); $store->save(); Inertia::flash('toast', ['type' => 'success', 'message' => $store->isPublished() ? __('Saved. Click "Publish changes" to show it on your live store.') : __('Style saved.')]); return to_route('stores.show', $store->slug); } }